百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
C

codemirror-rails

> 编程语言
开源

使用 CodeMirror 与 Rails 结合

160 stars0 点赞5 次浏览
访问官网GitHub

工具介绍

使用 CodeMirror 与 Rails 结合

codemirror-rails

Wire up the CodeMirror assets for your Rails applications.

Getting Started

If you're using Bundler, you can add codemirror-rails to your Gemfile:

ruby
gem 'codemirror-rails'

Or manually install the codemirror-rails gem:

bash
gem install codemirror-rails

CodeMirror for Rails >= 3.1

All of the assets from the most latest stable CodeMirror release are vendored so that you can use them with the asset pipeline. At a minimum, you will probably want the following in your application.js:

javascript
//= require codemirror

And in your application.css:

css
/*
*= require codemirror
*/

Adding a mode

Additional syntax modes can be added to your application.js:

javascript
//= require codemirror/modes/ruby

Adding an addon

Additional addons can be added in your application.js:

javascript
//= require_tree codemirror/addons/dialog

And your application.css:

css
/*
*= require_tree codemirror/addons/dialog
*/

Adding a keymap

Additional keymap bindings can be added to your application.js:

javascript
//= require codemirror/keymaps/vim

Adding a theme

Additional CSS themes can be added to your application.css

css
/*
*= require codemirror/themes/night
*/

Precompiling Codemirror

If your project is using precompiling, depending on your method of grabbing files to precompile, you might need to add the below line to your ```` application.rb```, to get rails to precompile all js, css files used by codemirror. You can also manually whitelist only the files that you use.

rb
config.assets.precompile += ["codemirror*", "codemirror/**/*"]

CodeMirror for Rails 3

You can use the generator included with this gem to copy the CodeMirror 2 assets into your Rails 3 public directory.

bash
rails generate codemirror:install

Contributing

Find a mistake? New version of CodeMirror? Submit a pull request!

Issues· 7 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Ruby

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言