Questions tagged [template-toolkit]

The Template Toolkit is a fast, flexible and, highly extensible template processing system for Perl. There are also Python and JavaScript implementations.

The Template Toolkit is a fast, flexible and highly extensible template processing system. It is Free (in both senses: free beer and free speech), Open Source software and runs on virtually every modern operating system known to man. It is mature, reliable and well documented, and is used to generate content for countless web sites ranging from the very small to the very large.

It is written in the Perl programming language but you don't need to know any Perl to use it. In fact, it was specifically created to allow web designers and developers to concentrate on generating web pages without getting bogged down in programming matters. We call this a "Clear Separation of Concerns" and it makes the whole processes of building, updating and maintaining a web site or web application significantly easier.

References:

266 questions
5
votes
2 answers

Perl Dancer Template headers, footers

I'm learning Perl and using Dancer as a web framework. I've got two views (tt files) which should share the same navigation. So, it would be great to start learning how to manage templates for navigation and footers. I've read the documentation…
Chüngel
  • 375
  • 4
  • 19
5
votes
2 answers

Trying to create a string with template values and unit test that the template is processing correctly

I am trying to create a test file that inputs template values into a string using the template toolkit but I don't know what check/tests to include to make sure the template toolkit is processing the string correctly. Here is my code: #!/usr/bin/env…
Paul Russell
  • 179
  • 10
5
votes
1 answer

Can I set up template inheritance inside a template? (Template Toolkit)

I have to display different medical forms according to which state the user is in. There is also a default form that many of the states share. These medical forms are all written in Template Toolkit and they are included in larger templates. The…
Schwern
  • 153,029
  • 25
  • 195
  • 336
5
votes
3 answers

Parse and display MIME multipart email on website

I have a raw email, (MIME multipart), and I want to display this on a website (e.g. in an iframe, with tabs for the HTML part and the plain text part, etc.). Are there any CPAN modules or Template::Toolkit plugins that I can use to help me achieve…
aidan
  • 9,310
  • 8
  • 68
  • 82
5
votes
1 answer

What is the difference between [% %] and [%- -%] in Template Toolkit?

What is the difference between [% %] and [%- -%] in Template Toolkit?
Gaurav Rathi
  • 93
  • 10
5
votes
3 answers

How can I write a Template.pm filter to generate PNG output from LaTeX source code?

I am looking for a way of generating PNG images of equations from LATEX source code embedded in templates. For example, given: [% FILTER latex_display ] \begin{eqnarray*} \max && U(x,y) \\ \mathrm{s.t.} && p_x x + p_y y \leq I \\ && x \geq 0, y \geq…
Sinan Ünür
  • 116,958
  • 15
  • 196
  • 339
5
votes
3 answers

How can I handle template dependencies in Template Toolkit?

My static web pages are built from a huge bunch of templates which are inter-included using Template Toolkit's "import" and "include", so page.html looks like this: [% INCLUDE top %] [% IMPORT middle %] Then top might have even more files…
user181548
5
votes
1 answer

Template::Toolkit don't evaluate variable as string

I'm using Template::Toolkit and within a for loop I am trying to change the timezone of an object: [%- FOR item IN c.user.items -%] [% item.date.set_time_zone(c.user.timezone.name) %] Date: [% item.date %]
[% END %] It works and it…
srchulo
  • 5,143
  • 4
  • 43
  • 72
5
votes
1 answer

How can I get elements out of an array with Template Toolkit?

I have an array of Paths which i want to read out with Template Toolkit. How can I access the array Elements of this array? The Situation is this: my @dirs; opendir(DIR,'./directory/') || die $!; @dirs = readdir(DIR); close DIR; $vars->{'Tree'} =…
Przemek
  • 623
  • 2
  • 11
  • 24
5
votes
1 answer

Is there a way to compare two variables in Template Toolkit?

[% IF OrgType.id == Organization.org_type_id %]selected="selected"[% END %] Does not work even when they both evaluate to the same number. [% IF OrgType.id == 3 %]selected="selected"[% END %] (i.e. hard-coding in a number for testing purposes)…
Devin Ceartas
  • 4,743
  • 1
  • 20
  • 33
5
votes
2 answers

Using a variable to access hash keys in Template Toolkit

I have an array whose contents is $VAR1 = { '1' => 'May 05, 2011', '0' => 'Jul 22, 2009', '2' => 'Jun 13, 2012' }; I am trying to display it in the catalyst template, the code is [% x = 0 %] [% FOREACH mortgage IN mortgages %]
Jitesh
  • 345
  • 1
  • 5
  • 16
5
votes
4 answers

Line numbers with template toolkit

I am using the Perl Template Toolkit to generate C files. I dearly want to be able to include #line directives in my C code so that error messages from the C compiler send me to the right place (the template file) rather than the wrong place (the…
user181548
5
votes
1 answer

Perl dancer and Template Toolkit: Including template within template

I am trying to INCLUDE a template within a template, like so: parent.tt
[% INCLUDE my_sidebar]
my_sidebar.tt exists in same folder as parent.tt (/myapp/views) I…
5
votes
2 answers

How to convert perl hash to javascript hash

I am working in template toolkit framework. I have got an perl hash datatype in my tt file. I want to convert this hash datatype to javascript hash datatype. code: template: [% PERL %] use JSON qw(encode_json); my $vars =…
Kalai
  • 81
  • 1
  • 3
5
votes
1 answer

How can I render only a specific `BLOCK` in a Perl's Template Toolkit?

How can I render only a specific BLOCK in a template? Suppose I have this BLOCK in text.tt, a Template Toolkit file: [% BLOCK someblock %] some block test blah blah blah [% END %] I want to be able to use process() to handle just that…
Sam Lee
  • 7,049
  • 10
  • 42
  • 47
1 2
3
17 18