template-toolkit

Formatting timestamp field for output in TemplateToolkit

独自空忆成欢 提交于 2019-12-06 09:50:54
问题 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 value is in such format 2012-08-30 21:30:14 , but when I print the value in TT view file I get it like this 2012-08-30T15:03:13 , so obviously it gets formatted but by what exactly I can't tell. I want to use Template::Plugin::Date to format output timestamps, but I get Catalyst error: Couldn't render

List of paths into hash array tree in Perl

﹥>﹥吖頭↗ 提交于 2019-12-05 20:00:43
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 = [ { name => "C:", subs => [ { name => "A", subs => [], }, { name => "B", subs => [ { name => "C", subs => [], } ], } ] }, { name => "D:", subs => [ { name => "AB", subs => [], } ], } ] I also know that I'm probably doing brainderp here so I'm open to other approaches, only requirement is turning that list of paths into something you can rebuild as a tree with the TT2 Template Toolkit. Also what's that structure called? I just

Formatting timestamp field for output in TemplateToolkit

荒凉一梦 提交于 2019-12-04 15:14:37
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 value is in such format 2012-08-30 21:30:14 , but when I print the value in TT view file I get it like this 2012-08-30T15:03:13 , so obviously it gets formatted but by what exactly I can't tell. I want to use Template::Plugin::Date to format output timestamps, but I get Catalyst error: Couldn't render template "xxx/list.tt2: date error - bad time/date string: expects 'h:m:s d:m:y' got: '2012-08-30T21

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

让人想犯罪 __ 提交于 2019-12-04 14:48:41
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 the requirements: make a web form where you can upload a CSV file containing a list of URLs when the user clicks "submit", the server fetches the file, and checks each URL to see if its alive, and what the title tag of the page is. the result is a downloadable CSV file containing the URL, and the result HTTP code the input CSV can be very large ( >

Can Perl's Template Toolkit warn on undefined values?

佐手、 提交于 2019-12-03 10:42:18
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 undefined values, if possible, and to log messages to STDERR. jrockway Yes. If you pass the DEBUG option to Template->new , TT will warn you about undefined values. See the docs here: http://search.cpan.org/dist/Template-Toolkit/lib/Template/Manual/Variables.pod Jon Ericson You are looking for: DEBUG_UNDEF This option causes the Template Toolkit to

Perl: Alternatives to template toolkit

你说的曾经没有我的故事 提交于 2019-12-03 03:47:27
问题 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 the correct line number information to debug the error. e.g. I would get a message indicating "0 is not defined" since I would be using [%x.0%] and similar constructs at multiple locations in the file figuring out which line has the problem becomes

How do I handle errors in methods chains in Perl?

寵の児 提交于 2019-12-02 23:57:12
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 = $obj->get_obj->get_other_obj->get_another_obj->do_something; What the best way to do it? Do I have to wrap in a try/catch/finally statement everytime? The context I want to apply this is: Im working in web development using Catalyst and DBIC and I do a lot of chained resultsets and if some of this resultset throw an exception I just want to assign a value of 0 or undef and then treat this error in the

Perl: Alternatives to template toolkit

女生的网名这么多〃 提交于 2019-12-02 15:58:58
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 the correct line number information to debug the error. e.g. I would get a message indicating "0 is not defined" since I would be using [%x.0%] and similar constructs at multiple locations in the file figuring out which line has the problem becomes difficult. TT3 seems to be under development indefinitely My question to the gurus is is there a better

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

偶尔善良 提交于 2019-12-01 15:03:24
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 because of the hyphen. [% artist.'life-span' %] ^This fails because the syntax is incorrect. [% lifespan = 'life-span' %] [% artist.$lifespan %] ^This works, but is impractical in a large app with lots of data. Is there a better way? The project I'm working on is a Catalyst based web app and the data comes from a number of different external web services, so I do

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

我的梦境 提交于 2019-12-01 13:54:02
问题 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 because of the hyphen. [% artist.'life-span' %] ^This fails because the syntax is incorrect. [% lifespan = 'life-span' %] [% artist.$lifespan %] ^This works, but is impractical in a large app with lots of data. Is there a better way? The project I'm working on is