Am 31.05.2012 20:38, schrieb simendsjo:

On Thu, 31 May 2012 19:27:07 +0200, Richard Kubina rjkubina@gmail.com
wrote:

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

If I'm not mistaken (noob here too), #{variable} is variables you pass
to the template from your code, or variables you create in the diet
template.
You can call functions be prepending an -

block body
-auto msg = hello();
p #{msg}

it might also work with
-auto msg = hello();
p= msg

Or even (but I dont think so):
p= hello();

All three methods should work, except that "p= ..." expects an
expression, so it's just "p= hello()".

You might need to import your file first, but that is as easy as:

  • import yourmodule;

Thanks to D's function local imports! Nice little feature.

Btw. a reference for the template syntax is on my TODO list for the next
days.