<div dir="ltr">Hi Gabor,<div><br></div><div style>I hope things are good with you.</div><div style><br></div><div>I was doing something somewhat similar. I ended up creating a custom view class since i had the same  issues with adding to the TT INCLUDE_PATH.</div>
<div><br></div><div style>Here is quick blog post with code on what i did: <a href="http://blog.leecarmichael.com/2013/03/altering-tts-includepath-in-dancer-with.html">http://blog.leecarmichael.com/2013/03/altering-tts-includepath-in-dancer-with.html</a></div>
<div style><br></div><div style>Sorry its not too verbose but please ask any questions and I&#39;ll do my best to remember WTF i was doing back then :)</div><div style><br></div><div style>Take Care,</div><div style><br></div>
<div style>Lee</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Mar 28, 2013 at 4:38 AM, Gabor Szabo <span dir="ltr">&lt;<a href="mailto:gabor@szabgab.com" target="_blank">gabor@szabgab.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
The <a href="http://perl5maven.com/" target="_blank">http://perl5maven.com/</a> site is using Dancer and Template::Toolkit.<br>
Since the opening of the Brazilian Portuguese translation at<br>
<a href="http://br.perl5maven.com/" target="_blank">http://br.perl5maven.com/</a><br>
They both run from the same instance of the application.<br>
<br>
I made some change to accommodate for the multiple language - the source of<br>
the pages are in separate directories now, and in the config.yml I<br>
have a section<br>
with some configuration parameters for each site.<br>
The application itself looks at request-&gt;host and pick the correct<br>
part of the configuration.<br>
<br>
So far it was good, but there were a few things that were left in<br>
English in the Portuguese site,<br>
and some things where I had both the English and the Portuguese text<br>
in the central template.<br>
As I am expecting a few more translations to appear[1] I wanted to<br>
split some of the templates too.<br>
<br>
The problem I found is that I cannot set the  INCLUDE_PATH dynamically<br>
as I don&#39;t seem<br>
to have access to the Template::Toolkit object. If I am not mistaken<br>
it is located in the<br>
$_engine variable in the Dancer::Template::TemplateToolkit module and<br>
it is not accessible<br>
from the outside world.<br>
<br>
So what I did was adding the following to the before hook:<br>
<br>
# Create a new Template::Toolkit object for every call because we<br>
cannot access the existing object<br>
# and thus we cannot change the include path before rendering<br>
my $engines = config-&gt;{engines};<br>
$engines-&gt;{template_toolkit}{INCLUDE_PATH} = [&quot;$appdir/views&quot;,<br>
mymaven-&gt;{articles} . &#39;/templates&#39;];<br>
Dancer::Template::TemplateToolkit-&gt;new( name =&gt; &#39;template_toolkit&#39;,<br>
type =&gt; &#39;template&#39; , config =&gt; $engines-&gt;{template_toolkit});<br>
<br>
<br>
This is hacky. Do you have a better suggestion to solve this issue?<br>
<br>
<br>
regards<br>
   Gabor<br>
<br>
[1] If you know someone who&#39;d be interested in helping in<br>
translations, please let me know.<br>
_______________________________________________<br>
dancer-users mailing list<br>
<a href="mailto:dancer-users@dancer.pm">dancer-users@dancer.pm</a><br>
<a href="http://lists.preshweb.co.uk/mailman/listinfo/dancer-users" target="_blank">http://lists.preshweb.co.uk/mailman/listinfo/dancer-users</a><br>
</blockquote></div><br></div>