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
19
votes
1 answer

How can I handle hash keys containing illegal identifier characters in Template Toolkit?

In Template Toolkit, if I have the following variable containing a hashref: [% artist = { 'life-span' => '1975 to 1987', } %] What is the best way to output the data in 'life-span'? I have tried... [% artist.life-span %] ^This fails…
nick
  • 1,369
  • 2
  • 13
  • 28
15
votes
2 answers

Can Perl's Template Toolkit warn on undefined values?

Is there a way to make Perl's Template display warnings for all undefined values that I attempt to use the GET directive on (via [% %]) during Template::process? The default behavior is to ignore and move on. I'd like to warn only in the case of…
cdleary
  • 69,512
  • 53
  • 163
  • 191
15
votes
5 answers

Perl: Alternatives to template toolkit

I have been using template toolkit for extending an existing domain specific language(verilog) for over 3 years now. While overall I am happy with it, the major irritant is that when there is a syntax/undef error the error message does not contain…
vijayvithal
  • 551
  • 1
  • 5
  • 13
13
votes
4 answers

How can I start out with web development using Perl?

I want to be able to create web front-ends to my Perl programs. I have a lot of experience with Perl, and I have converted most of my code to Modern Perl paradigms championed by Chromatic. I have ZERO experience writing web pages though. (The…
BackPacker777
  • 673
  • 2
  • 6
  • 21
12
votes
3 answers

escape HTML by default in Template Toolkit

Can I somehow configure Template Toolkit so that: [% foo %] does what you would now need to say: [% foo | html %] that is, escape HTML in foo? And do something else, like: [% foo | noHtml %] if I don't want to escape?
JoelFan
  • 37,465
  • 35
  • 132
  • 205
12
votes
1 answer

How can I profile template performance in Template::Toolkit?

What's the best method for benchmarking the performance of my various templates when using Template::Toolkit? I want something that will break down how much cpu/system time is spent processing each block or template file, exclusive of the time…
Adam Bellaire
  • 108,003
  • 19
  • 148
  • 163
11
votes
2 answers

How do I eliminate TT's "Wide character in print" warning?

I have this warning every time I run my CGI-script (output is rendered by Template::Toolkit): Wide character in print at /usr/local/lib/perl5/site_perl/5.8.9/mach/Template.pm line 163. What's the right way to eliminate it? I create the tt…
planetp
  • 14,248
  • 20
  • 86
  • 160
10
votes
3 answers

How do I handle errors in methods chains in Perl?

What is the best way to deal with exceptions threw in a method chaining in Perl? I want to assign a value of 0 or undef if any of the methods chained throw an exception Code sample: my $x =…
nsbm
  • 5,842
  • 6
  • 30
  • 45
10
votes
4 answers

What's the right way to display a DBIx::Class ResultSet in my Catalyst project that uses Template Toolkit?

Given a DBIx::Class resultset, for example: my $rs = $c->model("DB::Card")->search({family_name => "Smith"}); the tutorials I've read use the stash to pass an arrayref of rows: $c->stash->{cards} = [$rs->all]; This results in the query getting…
Thelema
  • 14,257
  • 6
  • 27
  • 35
9
votes
3 answers

Template toolkit IF on an empty array ref returns true, can I make it false?

So it seems that if I give template toolkit a reference to an array as a parameter ARRAY_REF => \@array and then have the following code in a template [% IF ( ARRAY_REF ) %] Do something [% ELSE %] Do something else [% END %] The else case…
cjh
  • 1,113
  • 1
  • 9
  • 21
8
votes
1 answer

template toolkit displays unique row

I am using Perl dancer2 to write an application. Running select query in mysql displays all records. But the same query run in dancer2 and template toolkit displays only unique records. Eg. 34 records fetched when this is run in mysql client. …
W R
  • 83
  • 1
  • 5
7
votes
1 answer

Is there a Catalyst tutorial that uses HTML::Template instead of TT?

I've been looking through a couple of Catalyst tutorials and they all tend to use Template Toolkit instead of HTML::Template. I've spent a lot of time with HTML::Template and I like it, and while I can see the power of TT, I don't know it, and I…
AmbroseChapel
  • 11,957
  • 7
  • 46
  • 68
7
votes
2 answers

Template toolkit character encoding

it seems like template toolkit isn't handling encoding properly. I am passing template->process a filename (where to get the template), a hash reference (containing all the parameters), and a scalar reference (where to put the output) then I am…
cjh
  • 1,113
  • 1
  • 9
  • 21
7
votes
1 answer

Get WRAPPER functionality from Template::Toolkit in Text::Xslate

I've used Template::Toolkit for my last few Catalyst projects and have a set up that I like using that allows a clean separation of my templates. Now I'm hoping to use Text::Xslate, but I'm having trouble figuring out if I can do my same setup or…
srchulo
  • 5,143
  • 4
  • 43
  • 72
7
votes
2 answers

Viewing the variable content in a clean way

So the way I'm using to view a variable content is to use Data::Dumper in my template toolkit: [% USE Dumper %] [% Dumper.dump(varname) %] But the result I get is kind of a big mess - all the info about table relations, column types and attrbitues…
kK-Storm
  • 474
  • 1
  • 4
  • 16
1
2 3
17 18