From: Navindra Umanee Date: 2005-07-17T05:57:54+09:00 Subject: Re: delaying string evaluation Hi James, James Edward Gray II wrote: > But if you've found what works for you, far be it from me to > complain. I was just making sure you were aware of another option. Thanks a lot for the info, I really appreciate it actually. > Off the top of my head: > > * ERb's <% ... %> flow control construct. > * ERb's handy "% ... entire line of code ..." shortcut. #{} allows arbitrary flow control of course. I think I can see where ERB might have an edge in that it is easier to mix fixed strings with Ruby code output. > * The ability to control spacing as you can with the special string > ERb's constructor takes. I suppose I do sometimes end up with an extra \n here and there. I haven't been bothered too much by it yet, because it generally doesn't affect HTML rendering at all. Another spacing problem right now is that I build my templates from a lot of sub-templates and I can't see an easy way to get the HTML indentation right because I never know what level I'm importing a sub-template at. I doubt ERb would be of help here though and this is basically only a concern regarding the readability of the HTML output. > * ERb's utility methods for HTML and URL escaping. Unless I'm misunderstanding something, those utility methods are replicated everywhere in Ruby. For example, CGI has its own copy of them and I think WEBrick does too. Typically the methods are only 1 or 2 lines... I'm already using my own version of them. Thanks a lot for the info! Let me know if I'm missing something. I'll start thinking about whether it's worth switching to ERB given the above. Cheers, Navin.