Am 06.01.2016 um 16:55 schrieb Martin Tschierschke:

I want to use the little function left:

 string left( string zeichen, int anzahl ){
    if( anzahl<zeichen.length ){
       return zeichen[0..(anzahl-1)];
    }
    return zeichen;
  }



Inside a Diet template. But after calling

 res.render!("template.dt",string_var,..,left)

I was only able to use:

 left(string_var,20)

not

 string_var.left(20)

which was possible inside main?

Why?
Sorry for the bad posts. Please delete...

This is a limitation of the language that might be lifted in the future.
Currently the uniform call syntax works only for globally defined
functions, but when passing the function alias as a template parameter
to render, the compiler sees a local symbol instead.

A way to work around this would be to import the function from within
the Diet template instead of passing it as a parameter:

- import main : left;
- string test = "hello".left(2);