Am 31.05.2012 19:27, schrieb Richard Kubina:
Hi, total noober here.
in my app.d i have added this function:
int hello(){
return 3;
}//end
..how can i call this function in my index.dt? I tried:block body
h1 Example page - Home
p hey #{hello()}did i miss the example in your documentation on the website? i got some
simple addition to work, but i can't call a function.thank you
You need to make the function visible to the template first. There are
three possibilities for this:
inside the template, import the module that defines the function:
block body
- import mymodule; h1 Example page - Home p hey #{hello()}
Pass the function as a template argument to res.render() - note that
res.render() has some issues in DMD 2.059 and I wouldn't recommend to
use it yet:res.render!("home.dt", hello);
Do the equivalent with res.renderCompat():
res.renderCompat!("home.dt", "hello")(Variant(&hello));
I've added a ticket for the website to remember adding an example to the
documentation.
Sönke