13

A number of sources (e.g. What is the meaning of erb? and three out of the top four results from this google search) cite http://ruby-doc.org/stdlib-1.8.7/libdoc/erb/rdoc/ERB.html as the official documentation on the ERB format, but that really just gives you the API rather than the file format.

I found a nice little summary in http://docs.puppetlabs.com/guides/templating.html#erb-template-syntax, but there's got to be something more official, right? And who is the "defining authority"? Did this come out of Rails?

Since some folks like to know motivation behind questions, I'm looking for documentation on the rather basic constraint that ERB tags cannot span multiple lines, which in turn arose from seeing multiple SO questions recently where the OP's were apparently unaware of this constraint.

Update: Given the Japanese heritage cited in @sawa's answer, allow me to clarify that I'm interested in the most official "English" version of the documentation.

Community
  • 1
  • 1
Peter Alfvin
  • 28,599
  • 8
  • 68
  • 106
  • Both <% and <%= can span multiple lines. Why do you think this is not possible? – iosctr Jan 05 '14 at 12:14
  • @iosctr - Well I was trying to clarify this for myself. And one reason to think it might not be possible is that none of the examples in any of the official(-ish) documents / tutorials show this. If you are new to ERB, and you have a bug in a template that you don't understand, it is *natural* (and wise) to question your assumptions ... and look for an official specification to clarify the matter! – Stephen C Jul 22 '14 at 23:14

1 Answers1

6

erb was developed by Masatoshi Seki as a Ruby implementation of eRuby, so its specification almost follows that of eRuby. One difference the author mentions is:

% cat hello.erb
Hello, <% print "World" %>.

% eruby hello.erb
Hello, World.

% erb hello.erb
WorldHello, .

in which case you can do:

% cat hello2.erb
Hello, <%= "World" %>.

% eruby hello2.erb 
Hello, World.

% erb hello2.erb
Hello, World.

to let them work the same way.

Here is an explanation about it by the author, and here and here are documentation written by the author.

sawa
  • 165,429
  • 45
  • 277
  • 381
  • 2
    LOL - literally. +1 and I'll update to acknowledge this and ask about an English translation or version. – Peter Alfvin Jan 03 '14 at 18:35
  • 2
    Accepting on the assumption that eRuby is acceptably documented on Wikipedia. That said, I _still_ can't find _any_ documentation which alludes to the fact that erb/eruby tags can span lines. All the examples involve single-line tags and there is no mention of tags spanning lines. – Peter Alfvin Jan 04 '14 at 23:48