问题
In Perl, by using Template Toolkit, here is what I do
Perl
my $vars = {
name => 'Count Edward van Halen',
};
$tt->process('letters/overdrawn', $vars)
|| die $tt->error(), "\n";
HTML
Dear [% name %],
In Mako template, how can I do so? Check through their render
function, doesn't get much hint.
回答1:
Use named arguments
mytemplate.render(myvar1="var1", mydict=dict())
In the mako side you'd do
${myvar1}
% for val in mydict:
${val}
% endfor
来源:https://stackoverflow.com/questions/4161464/pass-in-variable-to-mako-template