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.

template-toolkit
Filter by
Sorted by
Tagged with
4 votes
1 answer
1k views

Valid variable name in Template Toolkit

I'm using perl and Template::Toolkit to generate some texts. In the perl program, I defined a hash ref such as my $user = { "user-name" => "John" }; and passed it to Template::Toolkit in order ...
user avatar
4 votes
2 answers
346 views

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 ...
bliof's user avatar
  • 2,967
4 votes
3 answers
451 views

Perl Logic in Template Toolkit

I have a currency value that I would like to format using Locale::Currency::Format however I have no idea how to format it. Here is my output in Template Toolkit [% amount %] I would like this to ...
KingKongFrog's user avatar
  • 14.2k
4 votes
1 answer
4k views

How to Encode and Decode "Acute accented characters" using Perl

I am working in a web based educational website, where we are using Perl, MySQL 5, Apache and Template Toolkit. we are planning to introduce the support for multiple\ Language in our website. What we ...
Ash_and_Perl's user avatar
4 votes
2 answers
979 views

How to differentiate between false and defined values in Template Toolkit for perl

This is a question about Template Toolkit for perl. I render my templates with a little command-line utility that has the following option enabled DEBUG => Template::Constants::DEBUG_UNDEF, ...
az5112's user avatar
  • 630
4 votes
1 answer
229 views

Is it possible to use TT2 with Cro?

I am thinking of using perl6 and Cro to build a website with text content. Is there any best practice / guidance on using Cro with a template toolkit such as TT2 and code examples for me to leverage?
librasteve's user avatar
  • 7,156
4 votes
2 answers
1k views

How can I delete variable in Template Toolkit?

Looking at Template::Manual::VMethods section of the Template Toolkit manual I don't see any method doing this. Also assigning undef to variable doesn't work - variable.defined returns true after the ...
Piotr Dobrogost's user avatar
4 votes
1 answer
328 views

Is there a common intersection of Smarty and Template Toolkit?

In some projects I have to work with Perl and Template Toolkit and in others with PHP and Smarty templates. Can you somehow configure both to have a common subset of each language, so you can use the ...
Jakob's user avatar
  • 3,632
4 votes
1 answer
1k views

How do I use multiple Template Toolkit TTSite views on a Catalyst site?

I use Template Toolkit to generate views of pages in Catalyst. To do some basic Ajax, I want to have some output pages not use the TTSite style, but a much more basic structure. Do I put something ...
Thelema's user avatar
  • 14.4k
4 votes
1 answer
588 views

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}...
Twistar's user avatar
  • 782
4 votes
1 answer
529 views

Can I search resultset from within a toolkit template file?

I use Catalyst and put a resultset into the stash for TT to access: $c->stash->{tournament} = $c->model('DB::Tournament')->find($id); This class has a relationship with "...
Gunnar's user avatar
  • 361
4 votes
2 answers
469 views

How can I switch timezones in Perl's Template::Plugin::Date?

I have a calendar on my website, generated in Perl using Template::Toolkit and Template::Plugin::Date. It highlights the current day. I achieve this by iterating through all the dates (as I print the ...
aidan's user avatar
  • 9,446
3 votes
2 answers
2k views

Why can't I use Template Toolkit?

I am trying to use TemplateToolkit instead of good ole' variable interpolation and my server is giving me a lot of grief. Here are the errors I am getting: *** 'D:\Inetpub\gic\source\extjs_source....
Frew Schmidt's user avatar
  • 9,464
3 votes
2 answers
2k views

Can I find out if variable is an array using Template Toolkit?

I'm passing the results of a multi-select box to a page so that the selections can be shown on screen. As it's multi-select, the result can either be a scalar or an array reference. Is there a way of ...
dgBP's user avatar
  • 1,681
3 votes
2 answers
243 views

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'...
user avatar
3 votes
3 answers
2k views

How can you pass undef as an argument to an object method from a TT template?

Template-Toolkit seems to want to always interpolate undef to the empty string. So a template like this: Result is [% some_object.some_method (1, undef, 2) %] or this: Result is [% ttvar %] ...
F5.'s user avatar
  • 63
3 votes
3 answers
360 views

Where can I find 'more advanced web toolkit' for Template Toolkit?

I really like Template Toolkit and like how it works with Catalyst, but I would like more 'web advanced' toolkit. It could be just a package of *.tt files for Web objects like these: Selector, ...
sebthebert's user avatar
  • 12.3k
3 votes
2 answers
1k views

How to detect array type in Template toolkit? [closed]

I need to detect some variable for accessory to array type in Template toolkit. Are there best practices?
bibimij's user avatar
  • 117
3 votes
1 answer
1k views

How can I access elements of an array with Template Toolkit?

I would like to access element of array directly using template toolkit. e.g. we can easily do this, [% FOREACH item IN array %] [% item %] [% END %] Can I access directly 0th , 1st, 2nd etc. ...
mukesh bhoj's user avatar
3 votes
2 answers
856 views

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 ...
Eagle's user avatar
  • 3,414
3 votes
3 answers
598 views

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 ...
Nacho B's user avatar
  • 1,587
3 votes
2 answers
4k views

Perl Template::Toolkit regex matching either values

I am trying to match either of the string in the Perl Template::Toolkit module. url is getting its value from the script. [% IF url == ("a/b/c" | "d/e/f") %] Is this the right way of doing it? I ...
shakAttack's user avatar
3 votes
3 answers
3k views

List of paths into hash array tree in Perl

I got an array of paths C:\A C:\B\C D:\AB and I'd like to have these in a hash array tree so I can go through them in a TT2 template. What I mean is like this: @dirs = [ { ...
BloodyRain2k's user avatar
3 votes
2 answers
655 views

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); </%once> How can I do this in ...
cubabit's user avatar
  • 2,650
3 votes
1 answer
121 views

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 ...
Nazar's user avatar
  • 860
3 votes
1 answer
663 views

Perl Template Toolkit - how to return the template output result into a variable?

Perl Template Toolkit - how to return the template output result a into variable, so that it can be later processed or placed into a html layout using in a controller.
FantomX1's user avatar
  • 1,685
3 votes
1 answer
96 views

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 ...
Sherwood Botsford's user avatar
3 votes
1 answer
2k views

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 ...
nsbm's user avatar
  • 5,962
3 votes
1 answer
461 views

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' ...
dj_goku's user avatar
  • 117
3 votes
3 answers
3k views

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 ...
David Dombrowsky's user avatar
3 votes
2 answers
1k views

Using Template Toolkit to tick a checkbox without using multiple loops

I'm using Template Toolkit and perl to generate a web page. I have an array with ID numbers in it that toggle checkboxes on and off, if that value exists in the array. I was wondering if there is a ...
Vongrats's user avatar
3 votes
1 answer
469 views

Passing Objects into Template::Toolkit

I'm writing a script to pull my Stackoverflow activity feed into a webpage, it looks something like this: #!/usr/bin/perl use strict; use warnings; use XML::Feed; use Template; my $...
RobEarl's user avatar
  • 7,882
3 votes
2 answers
2k views

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 ...
Alan W. Smith's user avatar
3 votes
3 answers
460 views

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's user avatar
  • 2,967
3 votes
1 answer
276 views

why is Catalyst::Helper::View::TTSite deprecated?

I've just started getting into Catalyst, and I've been finding it really helpful. One of my favorite things about it was TTSite in that it got me going fast and gave me something to develop with ...
srchulo's user avatar
  • 5,193
3 votes
1 answer
299 views

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, $...
Imylor's user avatar
  • 384
3 votes
1 answer
2k views

Perl Catalyst - Couldn't render template..........not found

The error I am getting in the development server: [info] *** Request 2 (0.000/s) [681] [Thu Dec 12 21:05:39 2013] *** [debug] Path is "homescreen" [debug] "GET" request for "homescreen" from "192.168....
yonetpkbji's user avatar
  • 1,019
3 votes
2 answers
379 views

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 ...
Bubnoff's user avatar
  • 4,047
3 votes
2 answers
1k views

Syntax hightlighting of template toolkit files in Aptana/Eclipse

Does anyone know how I can add syntax highlighting to Eclipse/Aptana for Template Toolkit files? All I need is for [% ... %] to be a different colour.
Josef's user avatar
  • 31
3 votes
1 answer
628 views

How can I use a filter as a method in template toolkit?

I am trying to use the truncate filter on 2 variables (rsstitle and rssdescription), and assign the truncated version to a new variable (rsstitletrunc and rssdescriptiontrunc). I am relatively new to ...
nickelleon's user avatar
3 votes
1 answer
183 views

How can I do breaks and subtotals in a report?

I need to generate a business report using perl + Template Toookit and LaTeX. Things are working really well, but I am struggling with the problem of having breaks (for example page breaks, or ...
simone's user avatar
  • 4,953
2 votes
2 answers
853 views

Using Perl's Template.pm, how can I select a random element from an array and output it?

Suppose I have the following in my template: [%- pages = [ 'one', 'two', 'three' ] -%] <p>Go to page [%- ... -%]</p> Assuming EVAL_PERL is not set (i.e., I cannot use a [%- PERL -%] ...
Sinan Ünür's user avatar
2 votes
2 answers
3k views

how to check whether an element is present in an array using template toolkit

i am trying to find out whether an array contains an element in template toolkit. not sure how? can anyone help? my $var ={ myarray => ['a','c','b','d'] } passed to tt: now want to check: [% IF ...
rajeev's user avatar
  • 1,301
2 votes
2 answers
700 views

How can I force list context in Template Toolkit with RDBO?

I have a TT plugin that does the trivial unique ids: sub get_unique_uid_tt { my ( $classname, $o ) = @_; my %h; foreach my $item ( @{$o} ) { unless ( exists $h{ $item->id } ) { $...
Timmy's user avatar
  • 12.7k
2 votes
1 answer
2k views

Foreach hash with Perl template toolkit

I am using Perl template toolkit for rendering my data. This is the hash that I am passing to the template 'location' => { '1' => { 'nmi' => '...
Jitesh's user avatar
  • 345
2 votes
4 answers
3k views

Formatting timestamp field for output in TemplateToolkit

I'm using Perl with Catalyst framework, DBIx class as ORM, TT for views, Postgresql as DB. I have a column with 'timestamp without timezone' type, and if I do manual query in Postgres the column ...
kK-Storm's user avatar
  • 492
2 votes
2 answers
376 views

sprintf function in Perl catalyst template

Currently when I add this code [%mortgage.amortization_period%] it gives me output as 250000.00 But I need to remove that decimal points from there. Some times I need to remove only 1 digit after ...
Jitesh's user avatar
  • 345
2 votes
1 answer
138 views

Current template file name with Template::Toolkit

I have read through the Template::Toolkit documentation but could not figure out how to use template.name (the template being used). The string will be used to check =whether it's a particular ...
Chi Tran's user avatar
2 votes
1 answer
2k views

Syntax Highlighting for Template Toolkit (.tt files) in VIM

My goal is to get syntax highlighting for files using extension *.tt and so far it's been a frustrating "no" every time. I found the vim-perl plugin. Installed using legacy method 'make install' and ...
skippr's user avatar
  • 2,676
2 votes
1 answer
517 views

How to print recursive data structure with Template Toolkit?

I am trying to print a recursive data structure using Template Toolkit. How can I describe this in my template file? I have a data structure (Hash Array) with some elements like this ELEMENT -> ...
Andreas Zöllner's user avatar