Just Launched: You can now import projects and releases from Google Code onto SourceForge
We are excited to release new functionality to enable a 1-click import from Google Code onto the Allura platform on SourceForge. You can import tickets, wikis, source, releases, and more with a few simple steps. Read More
From: Matthew <matthew@ma...> - 2006-09-28 22:37:07
Is it possible to have a variable inside a variable be parsed?
I'd like to pull some text from DB containing a few tmpl_var's and
assign that text to a tmpl_var in original file I instantiated the
Is this possible?
From: Jonathan Lang <dataweaver@gm...> - 2006-10-04 03:39:16
> Is it possible to have a variable inside a variable be parsed?
> I'd like to pull some text from DB containing a few tmpl_var's and
> assign that text to a tmpl_var in original file I instantiated the
> object with.
> Is this possible?
HTML is very specific as to what it allows: when you pass a variable
into the template, you have to bear in mind which tag the variable is
going to be used in. A tmpl_var can only receive a string or a
number; I'm not even sure if it's permitted to take a boolean value,
although it might be. A tmpl_if/tmpl_unless can only receive a
boolean value. A tmpl_loop can only receive a list of hashes, and
tags nested within it access hash keys of the current iteration of the
loop instead of other variables passed into the template. There's a
flag you can use that lets nested tags access global variables as
well, as long as none of the hash keys clobber that name.
But there's no way to pass a simple hash or list into the template;
the _only_ aggregate data that HTML::Template handles is the list of
hashes used by tmpl_loop. Since tables are not a native data type for
perl, this makes it awkward for programmers to pass loop data into the
template; but then, HTML::Template seems to have a design philosophy
of keeping the template syntax as simple as possible at _all_ costs.
HTML::Template::Expr relaxes the straitjacket somewhat; but even that
much flexibility is viewed by the designer as a neccessary evil.
Jonathan "Dataweaver" Lang