N
Navindra Umanee
Hi,
I'm generating an HTML header as a String that makes heavy use of
interpolation. Essentially I have something like:
def make_html_header()
str <<END
blah #{blah} blah #{blah} blah #{blah}
END
end
This works great. Most of the interpolations are essentially
configuration parameters that I've elegantly stuffed into the instance
variables of a Singleton class, some are method invocations. These
parameters don't change often, if at all, and the header is more or
less identical for each HTML page that is generated.
So I would like to generate the header once and stuff it in an
instance variable. However, there are one or two variable
interpolations that are unique to each page e.g. the title of the
page.
How can I specify that some interpolations should be interpolated
immediately whilst a few others should be delayed until the next time
the String is evaluated? I can think of some hacky ways i.e. doing
subsequent string processing and substitions, I'm just wondering if
there is a more elegant way.
Also, where is the "<<MARKER" syntax (nothing in ri?) and Ruby string
interpolation officially documented, if anywhere?
Thanks,
Navin.
I'm generating an HTML header as a String that makes heavy use of
interpolation. Essentially I have something like:
def make_html_header()
str <<END
blah #{blah} blah #{blah} blah #{blah}
END
end
This works great. Most of the interpolations are essentially
configuration parameters that I've elegantly stuffed into the instance
variables of a Singleton class, some are method invocations. These
parameters don't change often, if at all, and the header is more or
less identical for each HTML page that is generated.
So I would like to generate the header once and stuff it in an
instance variable. However, there are one or two variable
interpolations that are unique to each page e.g. the title of the
page.
How can I specify that some interpolations should be interpolated
immediately whilst a few others should be delayed until the next time
the String is evaluated? I can think of some hacky ways i.e. doing
subsequent string processing and substitions, I'm just wondering if
there is a more elegant way.
Also, where is the "<<MARKER" syntax (nothing in ri?) and Ruby string
interpolation officially documented, if anywhere?
Thanks,
Navin.