Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perl dancer and Template Toolkit: Including template within template

I am trying to INCLUDE a template within a template, like so:

parent.tt

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

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

I have 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 %]

With RELATIVE

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.
like image 693
rajeshpalli Avatar asked Feb 12 '13 14:02

rajeshpalli


1 Answers

You need to include the full filename - my_sidebar.tt - in your INCLUDE. Dancer automatically appends a configurable extension (.tt by default) to the name of the main template, but TT doesn't know about that setting.

like image 87
Dave Sherohman Avatar answered Nov 07 '22 02:11

Dave Sherohman