Drastic proposal: rename eruby to rhtml to make way for an HTML free eruby filetype

Hugh Sasse hgs at dmu.ac.uk
Mon Mar 12 05:55:43 EDT 2007

On Fri, 9 Mar 2007, Tim Pope wrote:

> On Fri, Mar 09, 2007 at 04:39:20PM +0000, Hugh Sasse wrote:
> > > The subject says it all.  The most common use of eruby is filling out
> > > HTML templates, but this is by no means the only use.  I think it
> > 
> > No, see the book "Code Generation in Action" for example.  
> > 
> > http://www.codegeneration.net/tiki-index.php?page=GenerationBooks
> I'd say HTML templates are still the most common, due to Rails alone,
> but okay, you're actually helping make my case.
> > The difficulty I see is that when you mix syntaxes you have to pull
> > in the right syntax groups, and there isn't a *simple* way to do thig
> > in vim.  With lots of help from Doug and others I have, for example
> > in my .vimrc:
> > 
> > <snip>
> These look to be the opposite of ERB: other syntax embedded in Ruby
> rather than Ruby embedded in other syntax.

The principles still apply: to embed one syntax in another is not
trivial, except what you've written below challenges that.
> > Is the extension .erb already taken?
> The extension isn't the limiting factor, the filetype is.  Having erb
> for plain text and eruby for HTML is confusing.  However, it might be
> a good idea to use erb rather than eruby for the new file type, so
> that we end up with erb and rhtml.
> > Drat! :-)  I've answered the wrong question.  Hope soemthing in here
> > is of use...  In principle I'm in favour of encouraging this use of
> > eruby, mainly because I keep forgetting about it, and doing code generation
> > the hard way.  Hence all that sfuff in my vimrc.
> If you want to use ERB with C, attached is a proof of concept for you
> to try.  Drop it in ~/.vim/syntax/erb.vim.  Edit somefile.c.erb and
> and :set ft=erb.  This syntax file looks at the filename to determine
> what to embed.  So foo.c.erb will embed in C, foo.html.erb will embed
> in HTML, and foo.sql.erb will embed in SQL.  In fact, this script
> could be renamed to eruby.vim and it would more or less be a drop-in
> replacement, rendering my original suggestion moot.  But all the magic
> going on in the background is probably a bad idea.  If we get rid of
> the magic, having a file like this would still make using ERB with
> other file types a lot easier.
> if exists("b:current_syntax")
>   finish
> endif
> runtime! syntax/c.vim
> unlet b:current_syntax
> runtime! syntax/erb.vim
> let b:current_syntax = "erbc"
> That's all you would need in an erbc.vim to get ERB C highlighting.
OK, I'll have to have a go with this, and it's variants.  Thank you.

> Anyways, this is just wild brainstorming at this point.
> Cheers,
> Tim


More information about the vim-ruby-devel mailing list