htmlperltemplate-toolkit

Current template file name with Template::Toolkit


I have read through the Template::Toolkit documentation but could not figure out how to use template.name (the template being used). The string will be used to check =whether it's a particular template.

 [% SET name = template.name %]
  <span>[% IF name == 'ADMIN/MAIN.TT' %] YES [% ELSE %] NO [% END %]</span>

template.name returns admin/main.tt but it would not compare right. It keeps printing NO.


Solution

  • String comparison is case sensitive in Template Toolkit.

    [% IF name == 'admin/main.tt' %]