猎豹中的变量嵌套模板

时间:2011-01-22 13:14:57

标签: include cheetah

我有一个基本模板,它根据传入的变量调用嵌套模板,例如

page = 6

我想要的是调用一些html如下:

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

这是什么语法?感谢。

PS。我管理过这个:

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

但欢迎任何改进

1 个答案:

答案 0 :(得分:2)

好吧,所有这一切只是睡了几个晚上,但我得到了一个解决方案:

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

我略微扩展了代码并且它有效。 HTH

相关问题