J
James Edward Gray II
Can anyone explain the practical purpose of the final arg to ERB.new()
to me?
Thanks.
James Edward Gray II
to me?
Thanks.
James Edward Gray II
James said:Can anyone explain the practical purpose of the final arg to ERB.new()
to me?
James said:Can anyone explain the practical purpose of the final arg to
ERB.new() to me?
class ERB
def initialize(str, safe_level=nil, trim_mode=nil, eoutvar='_erbout')
...
end
end
You mean, +eoutvar+? That's the name of the variable that ERB uses
when it generates the Ruby code that corresponds to its input. That
variable will be used to build the output.
Try this:
require 'erb'
e = ERB.new( "One <%= ENV['HOME'] %> Two" )
p e.src
You'll see a variable _erbout initialized to the empty string, and
then the result of each operation concat'ed onto it.
I'm with ya to there. What would you use that for? Filling a
variable of your choice with the ERB source?
I've used it in the past to allow multiple ERB instances to be run
simultaneously within the same binding (ie, recursively).
So, is the conclusion that puts's and print's in ERB source will go to
STDOUT? Is there a way to have their output added to the ERB result?
This seems like an important behavior to support.
James said:Concat to eoutvar? Use <%= ... %> liberally?
James Edward Gray II
On a side note the commandline options to erb have a few issues.
First it says:
-d set $DBEUG to true
Anyone happen to know the difference between ERB.new("text").run and
ERB.new("text").result ?
Also, this has always bothered me, what is the difference between
eruby and erb? Just one is a compiled C extension or is there any
other reason?
James said:I'm confused. What's the problem here?
Well in Pickaxe 2 it says -d = set $DEBUG to true, so I'm guessing
this is a spelling mistake. Doesn't really matter, but I guess it's
in docs on the CLI options. I'm guessing it's actually $DEBUG, maybe
that could be fixed?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.