On Sat, 03 Nov 2012 15:49:01 GMT, denizzzka wrote:
extends layout block content -template v(string name){ string e = ""; static if (a==null) alias e v; else alias a.getValue!(name) v; }
Causes compile error:
layout.dt(2): Error: found 'template' instead of statement
layout.dt(2): Error: found '}' instead of statement
layout.dt(2): Error: found '}' instead of statement
layout.dt(2): Error: found '}' instead of statement
layout.dt(2): Error: found '}' instead of statement
layout.dt(2): Error: found '}' instead of statement
layout.dt(2): Error: found '}' instead of statementlayout.dt not contains any D code.
(And how to write multiple lines D code into templates?)
I'm afraid this is not possible. Templates can only be defined at global/module scope, but the code inside a diet template is internally always inserted at function scope.
Workaround is to define the template in a separate .d module and - import ...;
it.
Multiple lines would, in theory, work like this:
- template(string name)
- string e = "";
- static if (a==null)
- alias e v;
- else
- alias a.getValue!(name) v;