开发者

variable nested templates in cheetah

开发者 https://www.devze.com 2023-02-06 17:09 出处:网络
i have a base template that calls a nested template based on a variable passed in, eg. page = 6 and what i want is to call some html as follows:

i have a base template that calls a nested template based on a variable passed in, eg.

page = 6

and what i want is to call some html as follows:

...
<div>
    #include "templates/_page${page}.tmpl"
</div>
...

what is the correct syntax for this? thanks.

PS. i 开发者_开发问答have managed this:

#if $page.id == 6
    #include "templates/_page6.tmpl"
#end if

but any improvement welcome


well, all it took was a few nights sleep but i got a solution:

#include "templates/_page"+str($page)+".tmpl"

i slightly expanded the code and it works. HTH

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号