tags:

views:

17

answers:

2

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}

  {#template MAIN2}
    ...
  {#/template MAIN2}

Is this possible?

+1  A: 

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}

Solid Source
Thanks for the response... I was aware of this, but was wanting to have 2 MAIN templates in one file. From what I can tell, that is not possible.
Glen Little
A: 

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.

VallabhaV