Re: eruby delimiters
Shugo Maeda <[email protected]> Sat, 03 Jul 2004 03:52:03 +0900
| Newsgroups | gmane.comp.apache.mod-ruby |
|---|---|
| Message-ID | <[email protected]> |
Hi, Christian Luginbuehl wrote: > i've been working with mod_ruby and eruby for quite some time now and i am really impressed by it's ease of use. however i had a problem when parsing XML-files with embedded eruby code. at least libxml for ruby does not like the original delimiters. i found out, that in the file eruby_lib.c there are constants for beginning and ending delimiters to be set. but they would only work when they are 2 characters long. so i hacked the code a bit and made it work for beginning delimiters with variable length. > > i'm not quite sure if this is the right place to post a patch, but i still paste it here and wait for some reaction. I rejected same proposals before, but I changed my opinion. Because many people proposed it. But I think the default behaviour should not be changed. So `<?ruby' will be enabled by an option of configure.rb or a command line option. $ ./configure.rb --enable-xml or $ eruby --xml bar.txt (The name `xml' may not be appropriate.) > - i did not quite understand the part that does transform <%% to <% (and > simply removed it). why should this be done? is the % at the beginning > of a line of any use (this oen i didn't touch)? `<%%' is used to escape `<%'. This enables you to describe the syntax of eRuby in eRuby files. input for eruby: ----------------------- eruby converts <%% print "hello world" %> to <% print "hello world" %> ----------------------- output of eruby: ----------------------- eruby converts <% print "hello world" %> to hello world ----------------------- How do you think about the escape sequence for `<?ruby'? Then, % at BOL is used to avoid extra newlines. input for eruby: ----------------------- <ul> <% for i in ["foo", "bar", "baz"] %> <li><%= i %> <% end %> </ul> ----------------------- output of eruby: ----------------------- <ul> <li>foo <li>bar <li>baz </ul> ----------------------- You can eliminate these extra newlines by % at BOL. input for eruby: ----------------------- <ul> % for i in ["foo", "bar", "baz"] <li><%= i %> % end </ul> ----------------------- output of eruby: ----------------------- <ul> <li>foo <li>bar <li>baz </ul> ----------------------- Shugo