3

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.

Cheok Yan Cheng
  • 47,586
  • 132
  • 466
  • 875

1 Answers1

7

Use named arguments

mytemplate.render(myvar1="var1", mydict=dict())

In the mako side you'd do

${myvar1}
% for val in mydict:
    ${val}
% endfor
Novikov
  • 4,399
  • 3
  • 28
  • 36
  • `yourTemplateInstance.render(xyz = "value of xyz")` Check out http://diveintopython.org/power_of_introspection/optional_arguments.html – Novikov Nov 12 '10 at 03:57