Perl dancer and Template Toolkit: including a template in a template

I am trying to include a template in a template, for example:

parent.tt

  <div class="row-fluid">
    <div class="span3">
    [% INCLUDE my_sidebar]
    </div><!--/span-->
   </div>

my_sidebar.tt exists in the same folder as parent.tt (/ myapp / views)

I made the following changes to config.yml: With ABSOLUTE

template: "template_toolkit"
engines:
   template_toolkit:
     encoding:  'utf8'
     start_tag: '[%'
     end_tag:   '%]'
     ABSOLUTE : 1

parent.tt contains:

[% INCLUDE /myapps/views/my_sidebar %]

ATTITUDE

template: "template_toolkit"
engines:
   template_toolkit:
     encoding:  'utf8'
     start_tag: '[%'
     end_tag:   '%]'
     RELATIVE : 1
     INCLUDE_PATH: /myapps/views

parent.tt contains:

[% INCLUDE my_sidebar %]

But in both cases, I get the following error:

core - template - file error - my_sidebar: not found at /.../csm/64-bit/cpan/5.16.1-2012.09/lib/Dancer/Template/Abstract.pm line 90.
+5
source share
1 answer

You need to specify the full file name - my_sidebar.tt- in INCLUDE. Dancer automatically adds a custom extension ( .ttdefault) to the name of the main template, but TT is not aware of this setting.

+5
source

All Articles