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

template toolkit keep 20 first chrachters in a string

I am trying to remove everything from a string except the first 20 characters. But the regex removes the first 20 and keeps the rest. How can i solve this? Here is my code: [% p.name | remove('(.{20})', '$1') %] I have also tried this: [%…
Twistar
  • 782
  • 5
  • 21
  • 35
4
votes
2 answers

Template Toolkit include hook?

Is there some type of a hook that will be executed when I include a template and in which I can change the path to the template? e.g. [% INCLUDE test %] And I want to change the path to 'test' to be something like 'AE/test.tt' or 'FR/test.tt'. The…
bliof
  • 2,957
  • 2
  • 23
  • 39
3
votes
2 answers

How can I define constants in a Template Tookit template in a Catalyst app?

I want to use a constant in my TT template. In HTML::Mason (my previous templating engine of choice) I could do: <%once> use MyApp::Constants qw(CONSTANT); How can I do this in Template Toolkit? As mentioned in the title this is a Catalyst…
cubabit
  • 2,527
  • 3
  • 21
  • 34
3
votes
2 answers

How can I output perl Template Toolkit examples in Template ToolKit

I'm making some documentation for Template Toolkit via Template Toolkit files. The goal is to show the code that I'm using along with the outputs of the code. Right now, I'm doing this by making a copy of the code and replacing all the "%"…
Alan W. Smith
  • 24,647
  • 4
  • 70
  • 96
3
votes
3 answers

Moving logic from Template Toolkit to Catalyst

I think that I am using too much conditionals and calculations in the TT templates. I am displaying a result set of items from DBIc. For each item I need to calculate things using the retrieved values, and the template doesn't seems to be the right…
Nacho B
  • 1,573
  • 1
  • 12
  • 16
3
votes
2 answers

BASH: importing data from flat file into template

I have a flat file of records, each 33 lines long. I need to format this file to specs in a template. The template is in DOS format while the source file is in NIX format. The template has specific indenting and spacing which must be adhered to.…
Bubnoff
  • 3,917
  • 3
  • 30
  • 33
3
votes
1 answer

Add custom function to Tpage (Template::Toolkit)

I am using Tpage (a command line wrapper for the Template Toolkit) and the documentation describes how to create custom virtual methods for scalar, list or hash variables, which would then be called as variable.custom_method(). However, I would like…
Nazar
  • 820
  • 5
  • 13
  • 36
3
votes
3 answers

How to add a vmethod to template toolkit when using Dancer?

How to add a vmethod to template toolkit when using Dancer? If there isn't a way, how can I add a function /how to execute a ref to function which is added to the tokens/?
bliof
  • 2,957
  • 2
  • 23
  • 39
3
votes
1 answer

Filter items from a list using Template Toolkit

How can I filter some items that are in a dynamically generated list in Template Toolkit? I have a list of ids (also dynamically generated) and a list of ids to be excluded and I need to get just the ids that are not excluded. What the best way to…
nsbm
  • 5,842
  • 6
  • 30
  • 45
3
votes
1 answer

Perl - Template Alloy and Template toolkit array ref

I using template alloy and Template toolkit, in TT I want to detect array reference like i do with perl: for my $parents ( @{$value} ){ if (ref($parents) ne 'ARRAY'){ push @all_urls_names, $parents; } } This is my code in tt: use…
Imylor
  • 384
  • 1
  • 9
3
votes
1 answer

Accessing extra selected columns from a resultset inside Template Toolkit

my $rs = schema->resultset('Table1')->search( undef, { join => 'relationship_table2', '+select' => ['relationship_table2.fk_id','relationship_table2.order], '+as' => ['fk_id', 'order'], } ); Inside of template…
dj_goku
  • 117
  • 6
3
votes
1 answer

How do I use an arbitrary external program as a filter in a perl program?

I would like to use the current C version of Fletcher Penny's Multi-markdown as a filter in Template Toolkit. It's not clear to me how to set this up. At present I'm not calling TT as a module, but simply writing templates that are called with…
Sherwood Botsford
  • 1,889
  • 5
  • 20
  • 35
3
votes
3 answers

AJAX: how to get progress feedback in web apps, and to avoid timeouts on long requests?

This is a general design question about how to make a web application that will receive a large amount of uploaded data, process it, and return a result, all without the dreaded spinning beach-ball for 5 minutes or a possible HTTP timeout. Here's…
David Dombrowsky
  • 1,655
  • 3
  • 20
  • 32
3
votes
2 answers

Why doesn't die $template->error() show a line number?

In the following short program: use Template; my $template = Template->new (INCLUDE_PATH => "."); $template->process ("non-existent-file") or die $template->error (); why doesn't die produce a line number and newline? My output looks like…
user181548
3
votes
2 answers

How to pass arguments to a subroutine in template toolkit function

I my document foo.tt i would like to write something like this: [% INCLUDE header('str', 1, 2, 3, 5, 10) %] My aim is to do some string manipulation on str and then with foreach / for iterates over all the numbers. unfortunately i was unable to…
Eagle
  • 3,362
  • 5
  • 34
  • 46