Erb mode

795 views
Skip to first unread message

garga

unread,
Feb 11, 2008, 10:09:21 AM2/11/08
to Rails On Emacs
What mode do you use to edit erb templates? I'm not comfortable with
multi major modes approach. Does it make sense to create a separate
erb major mode that could highlight html, ruby, and erb code?

Dima

unread,
Feb 11, 2008, 10:56:48 AM2/11/08
to emacs-o...@googlegroups.com
Unfortunately currently emacs does not give good support multumode.
But it is possible to use various hacks, for example mmm-mode:

(require 'mmm-auto)
(setq mmm-submode-decoration-level 2)
(mmm-add-group
'fancy-html
'((html-erb
:submode ruby-mode
:match-face (("<%#" . mmm-comment-submode-face)
("<%=" . mmm-output-submode-face)
("<%" . mmm-code-submode-face))
:front "<%[#=]?"
:back "%>"
:insert ((?% erb-code nil @ "<%" @ " " _ " " @ "%>" @)
(?# erb-comment nil @ "<%#" @ " " _ " " @ "%>" @)
(?= erb-expression nil @ "<%=" @ " " _ " " @ "%>" @)))))

(add-to-list 'mmm-mode-ext-classes-alist '(html-mode nil fancy-html))

--
Best regards,
Dmitry Galinsky
http://dima-exe.ru

Peter Jones

unread,
Feb 11, 2008, 11:06:15 AM2/11/08
to emacs-o...@googlegroups.com

There was a thread about this a few days ago.

I use the rhtml mode from the rinari project:
http://rinari.rubyforge.org/

I'm only using the rhtml mode from rinari, and using emacs-on-rails
for everything else. It would be nice if those two project would
consider merging.

--
Peter Jones
http://pmade.com

Clinton R. Nixon

unread,
Feb 11, 2008, 11:13:33 AM2/11/08
to emacs-o...@googlegroups.com
On Feb 11, 2008 11:06 AM, Peter Jones <pjo...@pmade.com> wrote:
> I'm only using the rhtml mode from rinari, and using emacs-on-rails
> for everything else. It would be nice if those two project would
> consider merging.

Peter,

As I understand it, from a discussion at RubyConf, the same person is
maintaining both projects, so maybe there's hope of that in the
future.

- Clinton R. Nixon

garga

unread,
Feb 11, 2008, 1:19:30 PM2/11/08
to Rails On Emacs
Dima,

Do you plan to include something similar to rinary rhtml mode into
emacs-on-rails project?

Peter, thanks for the link. Looks like what I need.

Ignat.

mixandgo

unread,
Mar 14, 2008, 6:50:04 PM3/14/08
to Rails On Emacs
how do I add rhtml + rails-minor-mode to start when I open *.html.erb
files ?

or is there a better solution you guys are using ?

Peter Jones

unread,
Mar 20, 2008, 4:20:52 PM3/20/08
to emacs-o...@googlegroups.com
mixandgo wrote the following on Fri, Mar 14, 2008 at 03:50:04PM -0700:
> how do I add rhtml + rails-minor-mode to start when I open *.html.erb
> files ?

(autoload 'rhtml-mode "rhtml-mode" "RHTML" t)
(add-to-list 'auto-mode-alist '("\\.rhtml$" . rhtml-mode))
(add-to-list 'auto-mode-alist '("\\.html\.erb$" . rhtml-mode))

mixandgo

unread,
Mar 21, 2008, 11:00:55 PM3/21/08
to Rails On Emacs

> (autoload 'rhtml-mode "rhtml-mode" "RHTML" t)
> (add-to-list 'auto-mode-alist '("\\.rhtml$" . rhtml-mode))
> (add-to-list 'auto-mode-alist '("\\.html\.erb$" . rhtml-mode))

That will not load rails-minor-mode inside html.erb files right !?
Reply all
Reply to author
Forward
0 new messages