开发者

Named templates in jTemplate?

Is there any way to have multiple templates, and tell jTemplate which one to use? All examples I've seen always start with a template called MAIN.

I would like to put this into one template file:

  {#template MAIN1}
    ...
  {#/template MAIN1}

  {#templa开发者_Go百科te MAIN2}
    ...
  {#/template MAIN2}

Is this possible?


See: http://jtemplates.tpython.com/

Click on the "MultiTemplates" link under Documentation.

example:

* main template * (all part outside templates are invisible} {#template MAIN}

{$T.name.bold()} {#include table root=$T.table}

{#/template MAIN}


* main table * {#template table}

{#foreach $T as r} {#include row root=$T.r} {#/for}

{#/template table}


* for each row * {#template row} {$T.name.bold()} {$T.age} {$T.mail.link('mailto:'+$T.mail)} {#/template row}


We can pass parameters when calling template, pass some variables as parameters by using setParam method. By using $P.param_name, we can check the parameter value inside template and can include template based on the parameter.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜