On May 4, 2013, at 4:20 PM, CyrilG wrote:
> I am trying to load a page with different templates. The template number is passed in the url, which i convert to a jade variable and pass it to my page as follow:
>
> extends ../layout
> block content
>
div.page
> include template#{templateNumber}
>
> but I get an error "template#{templateNumber}. No such file or directory". If I replace it by " include template3", it works. It looks like jade processes the include before the variables . Any idea how I can fix that?
Includes are processed at template compile time, so you can't use them dynamically like that. You could maybe use a mixin or normal JS functions that happens to internally render another Jade template, but that comes with the associated performance cost. Overall it would probably be better to make each a top-level template just just extends a block in a shared template.
--Noah