html-template-users Mailing List for HTML::Template (Page 29)
Brought to you by:
samtregar
You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(42) |
Jul
(80) |
Aug
(77) |
Sep
(97) |
Oct
(65) |
Nov
(80) |
Dec
(39) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(63) |
Feb
(47) |
Mar
(45) |
Apr
(63) |
May
(67) |
Jun
(51) |
Jul
(78) |
Aug
(37) |
Sep
(45) |
Oct
(59) |
Nov
(50) |
Dec
(70) |
2004 |
Jan
(23) |
Feb
(90) |
Mar
(37) |
Apr
(53) |
May
(111) |
Jun
(71) |
Jul
(35) |
Aug
(58) |
Sep
(35) |
Oct
(35) |
Nov
(35) |
Dec
(20) |
2005 |
Jan
(51) |
Feb
(19) |
Mar
(20) |
Apr
(8) |
May
(26) |
Jun
(14) |
Jul
(49) |
Aug
(24) |
Sep
(20) |
Oct
(49) |
Nov
(17) |
Dec
(53) |
2006 |
Jan
(12) |
Feb
(26) |
Mar
(45) |
Apr
(19) |
May
(19) |
Jun
(13) |
Jul
(11) |
Aug
(9) |
Sep
(10) |
Oct
(16) |
Nov
(17) |
Dec
(13) |
2007 |
Jan
(9) |
Feb
(12) |
Mar
(28) |
Apr
(33) |
May
(12) |
Jun
(12) |
Jul
(19) |
Aug
(4) |
Sep
(4) |
Oct
(5) |
Nov
(5) |
Dec
(13) |
2008 |
Jan
(6) |
Feb
(7) |
Mar
(14) |
Apr
(16) |
May
(3) |
Jun
(1) |
Jul
(12) |
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
(9) |
2009 |
Jan
(9) |
Feb
|
Mar
(10) |
Apr
(1) |
May
|
Jun
(6) |
Jul
(5) |
Aug
(3) |
Sep
(7) |
Oct
(1) |
Nov
(15) |
Dec
(1) |
2010 |
Jan
|
Feb
|
Mar
|
Apr
(9) |
May
|
Jun
|
Jul
(5) |
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
2011 |
Jan
|
Feb
(3) |
Mar
|
Apr
(28) |
May
|
Jun
|
Jul
(3) |
Aug
(4) |
Sep
(3) |
Oct
|
Nov
(8) |
Dec
|
2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
(2) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(2) |
Dec
|
2016 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
From: Arka R. <ark...@ya...> - 2005-09-04 11:51:43
|
Hi! I am an experienced C/C++ PC application programmer but a complete newbie to Perl, CGI, HTML::Templates, and internet programming generally. I have created a simple sequence of forms, CGI scrips, and templates. I am sometimes getting an error displaying the final template in Internet Explorer when it is used under SSL. The "sometimes is the disconcerting part. My question here is not so much about SSL, but if what I am doing is valid in the first place. To sum up here is what I am doing. HTML file with form -> cgi script -> template with form -> cgi script -> template I am passing data from the forms to cgi via "post" and then using the Perl CGI "param" command. I am passing data from CGI to templates using $template->param(). I get the "The page cannot be displayed" error in IE at the last step, ie. when the last CGI script is trying to display the last template. The gory details are below, for your reference. But my question is pretty basic. Is is OK to display a template with a form in it, call a CGI from that form, and have that CGI display another template? Thanks, Arka Roy ---------------- Access: https://ssl.somedomain.com/Login.html | | V Login.html --------- - user fills form - user presses submit | | V DisplayForm.cgi --------- my $template = HTML::Template->new( filename => 'Form.tmpl' ); $template->param( displayValue => $myValue ); print "Content-Type: text/html\n\n"; print $template->output; | | V Form.tmpl --------- - displays <tmpl_var name="displayValue"> - user fills form - user presses submit | | V SubmitData.cgi --------- my $template = HTML::Template->new( filename => 'SubmitDone.tmpl' ); $template->param( displayResult => $myResult ); print "Content-Type: text/html\n\n"; print $template->output; | | V SubmitDone.tmpl --------- - displays <tmpl_var name="displayResult"> --------------------------------- Start your day with Yahoo! - make it your home page |
From: Mitar <mm...@gm...> - 2005-08-31 08:04:52
|
Hi! I think that it would be great if HTML::Template would have two additional "Filesystem Options". One would be to allow only relative filenames (that is filenames without "/" and "\" characters). So that user could not use absolute filenames. Other would be to check if the resulting file (file which HTML::Template found at the end of search to include) is not a symlink (file passes -f test and fails -l test). With this two options it would be possible to force using templates only from directories assigned by programmer. So it would be possible to let not fully trusted users to design templates. As those are really two simple if sentences which are tested only at a compile time (so there is no performance penalty) and are simple to implement from HTML::Template but impossible with filters I think you should really include them. Especially because there is still no new version with ELSE bugfix (khm, khm) so this could still be added to this future version. Best regards Mitar |
From: Sam T. <sa...@tr...> - 2005-08-30 17:41:40
|
On Tue, 30 Aug 2005, Octavian Rasnita wrote: > I have started to use the fast template HTML::Template::Compiled, but it > gives errors. Here is a test: HTML::Template::Compiled is not supported on this list, as far as I know. I'm not opposed to discussion of the module here but I thought you should know that this isn't the usual place for questions about it. -sam |
From: Octavian R. <ora...@fc...> - 2005-08-30 10:02:37
|
Hi, I have started to use the fast template HTML::Template::Compiled, but it gives errors. Here is a test: #The program: use HTML::Template::Compiled; my $ht = HTML::Template::Compiled->new(filename => 'index.html', path => 'e:/web/presaromana/test'); $ht->param({title => 'this is the title', desc => 'the desc',}); print $ht->output; #The template index.html: first line <TMPL_VAR NAME=title>, <TMPL_VAR NAME=desc> <TMPL_INCLUDE NAME=second.html> last_line #The template second.html: middle line #The result printed: Use of uninitialized value in concatenation (.) or string at E:/usr/site/lib/HTML/Template/Compiled.pm line 531. first line this is the title, the desc middle line last_line As you may see, the result printed is OK, but it also prints that error at the top. Am I missing setting some variables or something like that? Thanks. Teddy |
From: Brad C. <bra...@hi...> - 2005-08-22 19:57:16
|
I'm having problems getting <base href> to work in a particular scenerio. First, here's my file layout: Root: index.cgi [cgi-bin] -> contact.pl [pages] -> contact.tmpl -> topnav.tmpl -> thankyou.tmpl Now, here's the salient code INDEX.CGI: $template = HTML::Template->new(filename => 'pages/contact.tmpl'); CONTACT.TMPL: <base href="http://132.321.33.321/" /> <tmpl_include name="pages/topnav.tmpl"> <form action="../cgi-bin/contact.pl"...> TOPNAV.TMPL <tmpl_include name="../pages/topnav.tmpl"> ... <li><a href="?p=6">LINKS</a></li> ... 'Base href' works in the initial call of contact.tmpl from index.cgi in the root. But if contact.tmpl is called from cgi-bin/contact.pl, e.g.,if errors are found in validation and I'm returning the screen with 'associate', H::T returns an error that it can't find my includes. So, I dropped the <base href> and went to relative paths. It worked fine until I call thankyou.tmpl from contact.pl after the form is processed. The navigation is messed up because it's trying to do "cgi-bin/contact.pl?p=6" I tried: $template->param(HOME => $ENV{HOME}); $template->param(PATH => $ENV{PATH}); but the includes error occurs in the $template = HTML::Template->new(filename => '../pages/contact.tmpl'); Bottomline, is there a reason <base href> does not work when calling .tmpls from my cgi-bin/contact.pl? Thanks, Brad |
From: Thomas N. <th...@te...> - 2005-08-15 17:51:35
|
Hi I query mysql using fetchall_arrayref({}). I the dereference the AoH and delete any empty key->values. After that i wish to output the AoH to the template. However has =20 things stand now there are empty table headers. An illustrative example The query gets this result +-----------+-----------------------------+-------------------=20 +------------+-----------------+-------------------+-------------=20 +--------------------------------+ | Klient_ID | Namn | =20 Pnr | Ort | Telefon | =20 Telefax | Mobil | Epost | +-----------+-----------------------------+-------------------=20 +------------+-----------------+-------------------+-------------=20 +--------------------------------+ | 990 | AbbbCCCC | 1234567778 | Ume=E5 | =20 090-111111 | | | =20 ano...@sp... | | 991 | DDDDEEEE | 8522240000 | Ume=E5 =20 | | =20 | | | | 992 | FFFFFGGGG | 8234538525 | Ume=E5 | =20 090-333333| | =20 | | | 993 | HHHHIIIIII | 8134878510 | UME=C5 | =20= 090-222222 | | =20 | | | 994 | JJJJJKKKKK | 5810124598 | Lycksele =20 | | =20 | | | +-----------+-----------------------------+------------+------------=20 +-----------------+------------+-------------=20 +--------------------------------+ As we can se the fields Klient_ID, Namn, Pnr, Ort, Telefon, Epost =20 have at least one value in one row. The fields Mobil and Telefax have =20= no values. When i dreference I delete all key->value pairs where there is no value. In my template I have the following <th>Klient_ID</th> <th>Namn</th> etc for all the field names. This has the effect that I have empty tableheaders , for instance =20 Telefax is completely empty and should not be displayed. To fix this I would like to set the <th>value</th> dynamically frpm =20 my perlscript. Since I cannot know beforehand how many, if any, columns will be =20 empty I need som way to check for empty fields. I can get it to work =20 if my query only gets one hit, but I have been unable to do so if the =20= query generates more than one hit (i.e more than one row). I'm beginning to think that I am missing something fundamental - =20 something that perhaps seems simple - but at the moment I am at my =20 wits end. I would greatly appreciate it if someone could give me an idea of =20 what to do. Thomas |
From: Thomas N. <th...@te...> - 2005-08-12 14:47:58
|
Thanks.. I managed to figure it out but yor mail was very instructional. What I did was as follows ..some code... $rows = $sth->fetchall_arrayref({}); my @AoH = @$rows; for my $p (0..$#AoH) { for my $bulle ( keys %{ $AoH[$p] } ) { if (($AoH[$p]{$bulle}) =~ m/^[\d]+-[\d]+$/) { my @fields = split /-/, ($AoH[$p]{$bulle}); my $nr1 = "-"; my $nr2 = "-"; $rows->[$p]->{Mobil} = $nr1.$fields[0].$fields[1]. $nr2; } } } Its probably not elegant but it gives me a chance to change the value of row "Mobil" before feeding it to the template. In this particular example it doesn do anything useful I was simply doing it to learn. Your input was greatly appreciated and if you see me missing something obvious the give me a "holler". And thanks for the dumper idea..did really know about that. Thomas 12 aug 2005 kl. 16.06 skrev Ragan, Steve: > > To understand how to de-ref you must understand what it is you're > trying to de-ref. > > Lets assume you have a simple SQL query like this that returns > first and last names from a table - > > my $sql = qq[ > SELECT first, last > FROM persons > ]; > > First you prepare and execute - > > my $sth = $dbh->prepare($sql) || die("Unable to prepare > statement"); > > $sth->execute() || die("Database execute Error: $DBI::errstr"); > > then fetch the results. If you use the regular fetchall_arrayref(), > you're getting an arrarref of arrayref structure. > That is a reference to array of rows that itself is a reference to > array of columns. > To help visualize the structure you can use the Data::Dumper module > > use Data::Dumper; > > my $ra_results = $sth->fetchall_arrayref(); > > my $d = Data::Dumper->new([$ra_results], [qw(ra_results )] ); > > > print '<pre>' . $d->Dump . '</pre>'; # if you in HTML, > otherwise just print $d->Dump > > > The structure would appear something like this - > > $ra_results = [ > [ > 'Duane', > 'Allman' > ], > [ > 'Stevie Ray', > 'Vaughn' > ] > ]; > > > You could access specific rows and columns directly - > > First row - > > my $first_name = $ra_results->[0][0]; > my $last_name = $ra_results->[0][1]; > > or loop through all rows accessing each column - > > for my $ra_row (@{$ra_results}) { > my $first_name = $ra_row->[0]; > my $last_name = $ra_row->[1]; > ...( more code here ) ... > } > > > > > If you fetch using $sth->fetchall_arrayref({}), you're getting an > arrarref of hashref structure. > That is a reference to array of rows that itself is a reference to > a hash of column name/column values. > If you use Data::Dumper again you'll see the structure looks like this > > $ra_results = [ > { > 'last' => 'Allman', > 'first' => 'Duane' > }, > { > 'last' => 'Vaughn', > 'first' => 'Stevie Ray' > }, > ]; > > > You would loop through that structure like this - > > my $ra_results = $sth->fetchall_arrayref({}); > > for my $ra_row (@{$ra_results}) { > for my $key (keys %{$ra_row}) { > my $value = $ra_row->{$key}; > ...( more code here ) ... > } > } > > > If you're using TMPL_LOOP's you probably don't need to be munging > around with that data structure anyway since you need to assign an > arraryref of hasref to the param - > > $template->param(EMPLOYEE_INFO => $ra_results ); > > > Check out the perl doc perldsc (Data Structures Cookbook) for a > discussion on data structures and derefernencing. > > Good luck > Steve > (Programmer, not soda jerk :) > > > Steve Ragan > Sr. Internet Developer > Harris Connect > 2500 Westchester Ave. > Purchase, NY 10577 > T 914.641.3948 > F 914.641.3584 > sr...@ha... > www.harrisconnect.com > > > > -----Original Message----- > From: htm...@li... > [mailto:htm...@li...]On Behalf Of > Thomas Nyman > Sent: Friday, August 12, 2005 5:11 AM > To: htm...@li... > Subject: [htmltmpl] dereferencing issues > > > Hi > > I've tried studying perldoc pages, the htmps template pages and most > things relating to dbi etc. > > Despite this I have been unable to understand how to dereference > fetchall_arrayref({}) > > I can dereference fetchall_arrayref() but not fetchall_arrayref > ( {} ), i.e the arrayref of hash refs. > > I would like to query the database using fetchall_arrayref({}), the > dereference that and perhaps make changes to some values, put it back > into an arrayref({}) and then dump it to html template. > > SO far I'm stumped with the first part..i simply cant dereference the > *fg!?*-thing <grinning> .. anyway, please is there some who can help > iterate through arrayref({}) (both key and value). > > AN example > > I query the database for "Name", "Adress", "Phone", "Fax", "Email" > > the $rows = $sth->fetchall_arrayref({}); > > now i would like to dump my rows into an array and check for certain > values etc, for instance lets say the phonenumber is represented as > 512445566 in the database, but i want it to display as 512-445566 in > the html-template..therefore i would need to access the "Phone" > query, check its format, possibly change it, insert the new value in > my arrayref of hashrefs. > > (on my knees and waiting) > > Thomas > > > > ------------------------------------------------------- > SF.Net email is Sponsored by the Better Software Conference & EXPO > September 19-22, 2005 * San Francisco, CA * Development Lifecycle > Practices > Agile & Plan-Driven Development * Managing Projects & Teams * > Testing & QA > Security * Process Improvement & Measurement * http://www.sqe.com/ > bsce5sf > _______________________________________________ > Html-template-users mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/html-template-users > > ********************************************************************** > ********************************************************************** > **** > This message (including any attachments) contains confidential > information intended for a specific individual and purpose, and is > protected by law. If you are not the intended recipient, please > delete this message. Any disclosure, copying, or distribution of > this message, or the taking of any action based on it, is strictly > prohibited. > > NOTE: Effective immediately, our name has changed from Bernard C. > Harris Publishing Company to Harris Connect. As a result, our e- > mail domain name is changing from us...@bc... to > us...@ha.... Please make the appropriate adjustments to > any personal address book entries or contact information. > |
From: Thomas N. <th...@te...> - 2005-08-12 14:40:14
|
12 aug 2005 kl. 11.10 skrev Thomas Nyman: > Hi > > I've tried studying perldoc pages, the htmps template pages and > most things relating to dbi etc. > > Despite this I have been unable to understand how to dereference > fetchall_arrayref({}) > > I can dereference fetchall_arrayref() but not fetchall_arrayref > ( {} ), i.e the arrayref of hash refs. > > I would like to query the database using fetchall_arrayref({}), the > dereference that and perhaps make changes to some values, put it > back into an arrayref({}) and then dump it to html template. > > SO far I'm stumped with the first part..i simply cant dereference > the *fg!?*-thing <grinning> .. anyway, please is there some who > can help iterate through arrayref({}) (both key and value). > > AN example > > I query the database for "Name", "Adress", "Phone", "Fax", "Email" > > the $rows = $sth->fetchall_arrayref({}); > > now i would like to dump my rows into an array and check for > certain values etc, for instance lets say the phonenumber is > represented as 512445566 in the database, but i want it to display > as 512-445566 in the html-template..therefore i would need to > access the "Phone" query, check its format, possibly change it, > insert the new value in my arrayref of hashrefs. > > (on my knees and waiting) > > Thomas > > > > ------------------------------------------------------- > SF.Net email is Sponsored by the Better Software Conference & EXPO > September 19-22, 2005 * San Francisco, CA * Development Lifecycle > Practices > Agile & Plan-Driven Development * Managing Projects & Teams * > Testing & QA > Security * Process Improvement & Measurement * http://www.sqe.com/ > bsce5sf > _______________________________________________ > Html-template-users mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/html-template-users > Never mind guys .. I finally figured it out :) |
From: Thomas N. <th...@te...> - 2005-08-12 09:10:51
|
Hi I've tried studying perldoc pages, the htmps template pages and most things relating to dbi etc. Despite this I have been unable to understand how to dereference fetchall_arrayref({}) I can dereference fetchall_arrayref() but not fetchall_arrayref ( {} ), i.e the arrayref of hash refs. I would like to query the database using fetchall_arrayref({}), the dereference that and perhaps make changes to some values, put it back into an arrayref({}) and then dump it to html template. SO far I'm stumped with the first part..i simply cant dereference the *fg!?*-thing <grinning> .. anyway, please is there some who can help iterate through arrayref({}) (both key and value). AN example I query the database for "Name", "Adress", "Phone", "Fax", "Email" the $rows = $sth->fetchall_arrayref({}); now i would like to dump my rows into an array and check for certain values etc, for instance lets say the phonenumber is represented as 512445566 in the database, but i want it to display as 512-445566 in the html-template..therefore i would need to access the "Phone" query, check its format, possibly change it, insert the new value in my arrayref of hashrefs. (on my knees and waiting) Thomas |
From: Sam T. <sa...@tr...> - 2005-08-11 17:35:17
|
On Thu, 11 Aug 2005, Mitar wrote: > On 8/11/05, Mark Stosberg <ma...@su...> wrote: > > I've now submitted a patch with a test, code and docs to resolve this. > > It's available through rt.cpan.org: > > Oho, that was really fast. > > And when can we expect this in the official release, Sam? I'd like to release something next week. Bug me about it if that doesn't happen. Oh, and if anyone in the audience knows of a bug or a patch that's not in rt.cpan.org you may want to put it there. I'll comb through my inbox as I'm working on the release but stuff in RT is much harder to miss. -sam |
From: Mitar <mm...@gm...> - 2005-08-11 12:09:30
|
Hi! On 8/11/05, Mark Stosberg <ma...@su...> wrote: > I've now submitted a patch with a test, code and docs to resolve this. > It's available through rt.cpan.org: Oho, that was really fast. And when can we expect this in the official release, Sam? Mitar |
From: Mark S. <ma...@su...> - 2005-08-11 00:52:31
|
On 2005-08-10, Sam Tregar <sa...@tr...> wrote: > On Wed, 10 Aug 2005, Mitar wrote: > >> I think that HTML::Template should report this. Or is there some >> reason for it? I use the 2.7 version and Perl 5.8.4. > > Nope, that's a bug. Could you report it on rt.cpan.org? That will > ensure that I don't forget to fix it for the next release. I've now submitted a patch with a test, code and docs to resolve this. It's available through rt.cpan.org: http://rt.cpan.org/NoAuth/Bug.html?id=14097 Mark -- http://mark.stosberg.com/ |
From: Mark S. <ma...@su...> - 2005-08-10 23:22:10
|
You can now use much of Template Toolkit's dot notation with HTML::Template-- HTML::Template::Plugin::Dot has been uploaded to CPAN: http://search.cpan.org/~rhesa/HTML-Template-Pluggable-0.01/lib/HTML/Template/Plugin/Dot.pm It's a needs a minor patch to HTML::Template to work inside loops, which explained in the documentation. Enjoy! Special thanks to Rhesa Rozendaal for his contributions to this project. Mark -- http://mark.stosberg.com/ |
From: Sam T. <sa...@tr...> - 2005-08-10 17:49:06
|
On Wed, 10 Aug 2005, Mitar wrote: > I think that HTML::Template should report this. Or is there some > reason for it? I use the 2.7 version and Perl 5.8.4. Nope, that's a bug. Could you report it on rt.cpan.org? That will ensure that I don't forget to fix it for the next release. Thanks, -sam |
From: Mitar <mm...@gm...> - 2005-08-10 16:48:50
|
Hi! I have found a bug (or at least I think it is a bug and not a feature). For a really simple program: #!/usr/bin/perl -w use strict; use HTML::Template; my $template =3D HTML::Template->new('filename'=3D>"test.tmpl"); print $template->output; And this invalid template: Before. <TMPL_IF NAME=3D"TEST"> 1. <TMPL_ELSE> 2. <TMPL_ELSE> 3. </TMPL_IF> After. HTML::Template does not output any error and just simply outputs the 2. cas= e. I think that HTML::Template should report this. Or is there some reason for= it? I use the 2.7 version and Perl 5.8.4. Best regards Mitar |
From: Mark S. <ma...@su...> - 2005-08-10 03:31:51
|
On 2005-08-08, Mark Fuller <mar...@ea...> wrote: > From: "Mark Stosberg" <ma...@su...> >> > It sounds nice but I'd personally find it pretty useless. Most of my >> > use of HTML::Template involves inspecting the template with query() >> > and setting up the variables and loops that are actually requested. >> >> Interesting. I hadn't heard of that technique being used before. > > I've done it for a *long* time. It's great. It let's the template drive > common code. Is there is a generalized way to solve this, or do you have to write custom query functions every time? Mark |
From: Sam T. <sa...@tr...> - 2005-08-08 05:41:26
|
On Mon, 8 Aug 2005, Mark Stosberg wrote: > Interesting. I hadn't heard of that technique being used before. I do > recall that this feature could be accomplished somewhat automatically if > code refs were used for values-- the code refs would only be executed if > they were used. I have rarely needed that myself. For better or worse code-refs don't work for loops. I'll fix that someday! Also, setting up a code-ref takes time that query() can save you in many cases. > > Heh. Human-friendly YAML, huh? > > Yes. It's the first bullet point on the YAML website: > > "YAML documents are very readable by humans." I happen to disagree. YAML is more readable than a lot of serialization formats (probably all), but that doesn't make it fit for documentation! I'd call it "mostly readable by humans" I think. > > I'm fresh out of time to look at it more closely but I think you're on > > the right track. I'm not completely convinced it belongs in-core yet, > > There would be some immediate benefits. I believe being in-core would > mean my "Dot" plugin could be used with HTML::Template::Set immediately, > for those who cared to use both together. In the ::Pluggable sub-class, > ::Set has to be be re-written as a plugin to cooperate. I guess that's cool. It doesn't exactly compel me to action though. I tend to think of ::Set as an abomination better avoided than supported! > > if only because that would put you at the mercy of my absurdly slow > > release schedule... > > I'm really hoping the simple bug report for removing a hardcoded package > name can be released soon, because even as a ::Pluggable sub-class, we > depend on that patch. Yeah, I like that one. Since you've put it in RT I can virtually guarantee that it'll be in the next release. It's hard to forget things in RT. I'll try to grab some time to make a release soon. > I'm also help to with release engineering. For example, I could prepare > things in CVS and you could refine them for release, or basically > "bless" something if you liked it. Hmmmm. Maybe. You've been somewhat, how should I put it... hard to persuade. Here's how I'd like to proceed: you keep working on the pluggable magic in a sub-class. Keep me informed about stuff that absolutely has to be fixed in-core and I'll try to get the fixes out ASAP. Some ways down the line, possibly as part of the fabled HTML::Template 3.0 project, I'll see about merging in your sub-class. Sound workable? -sam |
From: Mark F. <mar...@ea...> - 2005-08-08 01:17:10
|
From: "Mark Stosberg" <ma...@su...> > > It sounds nice but I'd personally find it pretty useless. Most of my > > use of HTML::Template involves inspecting the template with query() > > and setting up the variables and loops that are actually requested. > > Interesting. I hadn't heard of that technique being used before. I've done it for a *long* time. It's great. It let's the template drive common code. Mark |
From: Mark S. <ma...@su...> - 2005-08-08 00:54:19
|
On 2005-08-07, Sam Tregar <sa...@tr...> wrote: > On Sat, 6 Aug 2005, Mark Stosberg wrote: > >> It should be easier for a designer to get an answer to the question: >> "What tokens do I have available?" >> >> I think there is a fairly reasonable way to make this easier. >> >> A <tmpl_dump> tag could be added which outputs all the possible >> tmpl_loop tmpl_var names, along with their values, right in the >> template. > > It sounds nice but I'd personally find it pretty useless. Most of my > use of HTML::Template involves inspecting the template with query() > and setting up the variables and loops that are actually requested. > This is how Krang works, for example. Interesting. I hadn't heard of that technique being used before. I do recall that this feature could be accomplished somewhat automatically if code refs were used for values-- the code refs would only be executed if they were used. I have rarely needed that myself. This seems like a reasonable default for people who aren't using die_on_bad_params (which seems to be a lot of users). >> It can output human-friendly YAML, which could simply be wrapped >> in a <pre> tag to complete the presentation. > > Heh. Human-friendly YAML, huh? Yes. It's the first bullet point on the YAML website: "YAML documents are very readable by humans." I agree, from looking at the example: http://www.yaml.org/start.html > I'd aim for something a little > friendlier than that - like formatted HTML. If the feature was implemented, I wouldn't argue over whether YAML or formatted HTML. > BTW - your pluggable stuff looks great. Thanks! > I'm fresh out of time to look at it more closely but I think you're on > the right track. I'm not completely convinced it belongs in-core yet, There would be some immediate benefits. I believe being in-core would mean my "Dot" plugin could be used with HTML::Template::Set immediately, for those who cared to use both together. In the ::Pluggable sub-class, ::Set has to be be re-written as a plugin to cooperate. > if only because that would put you at the mercy of my absurdly slow > release schedule... I'm really hoping the simple bug report for removing a hardcoded package name can be released soon, because even as a ::Pluggable sub-class, we depend on that patch. I'm also help to with release engineering. For example, I could prepare things in CVS and you could refine them for release, or basically "bless" something if you liked it. Of course, CVS is not the most flexible source control system. With a system like darcs, you could really "undo" a patch of mine you didn't like. While CVS, reversing or undoing a patch that touched multiple files would be rather painstaking. I've been doing something like this to help the CGI::Session 4.0 release get out the door using SVN. Mark -- http://mark.stosberg.com/ |
From: Philip T. <phi...@gm...> - 2005-08-07 20:19:34
|
Sometime on Aug 7, ST cobbled together some glyphs to say: > It sounds nice but I'd personally find it pretty useless. Most of my > use of HTML::Template involves inspecting the template with query() > and setting up the variables and loops that are actually requested. > This is how Krang works, for example. query() is good for programmers, not for web designers. The guys who work only the HTML need an HTML way of querying the template. -- Life is the living you do, Death is the living you don't do. -- Joseph Pintauro |
From: Sam T. <sa...@tr...> - 2005-08-07 17:57:10
|
On Sat, 6 Aug 2005, Mark Stosberg wrote: > It should be easier for a designer to get an answer to the question: > "What tokens do I have available?" > > I think there is a fairly reasonable way to make this easier. > > A <tmpl_dump> tag could be added which outputs all the possible > tmpl_loop tmpl_var names, along with their values, right in the > template. It sounds nice but I'd personally find it pretty useless. Most of my use of HTML::Template involves inspecting the template with query() and setting up the variables and loops that are actually requested. This is how Krang works, for example. > It can output human-friendly YAML, which could simply be wrapped > in a <pre> tag to complete the presentation. Heh. Human-friendly YAML, huh? I'd aim for something a little friendlier than that - like formatted HTML. BTW - your pluggable stuff looks great. I'm fresh out of time to look at it more closely but I think you're on the right track. I'm not completely convinced it belongs in-core yet, if only because that would put you at the mercy of my absurdly slow release schedule... -sam |
From: Mark S. <ma...@su...> - 2005-08-06 23:09:15
|
It should be easier for a designer to get an answer to the question: "What tokens do I have available?" I think there is a fairly reasonable way to make this easier. A <tmpl_dump> tag could be added which outputs all the possible tmpl_loop tmpl_var names, along with their values, right in the template. When the designer is done with this reference, it can be removed. I think the hard part of this implementation is already done, in the form of HTML::Template::Dumper which does basically just this. It can output human-friendly YAML, which could simply be wrapped in a <pre> tag to complete the presentation. All that's left to be done is to add the glue that supports calling this from a new tag. This is another example of a nice feature that could be implemented with a plugin system. I have contacted the author of HTML::Template::Set to see if he would like to make a plugin version of that extension as well. A sample of using HTML::Template::Dumper is below. Mark # Sample HTMl::Template::Dumper script and output #!/usr/bin/perl use lib './lib'; use HTML::Template::Dumper; my $t = HTML::Template::Dumper->new( scalarref => \'<tmpl_var outer><tmpl_loop deloop><tmpl_var inner></tmpl_loop>', ); $t->set_output_format('YAML'); $t->param( outer => 'My Outer', deloop => [ { inner => 'First Inner', }, { inner => 'Second Inner'} ], ); print $t->output(); # output --- #YAML:1.0 deloop: - inner: First Inner - inner: Second Inner outer: My Outer -- http://mark.stosberg.com/ |
From: Mark S. <ma...@su...> - 2005-08-06 22:26:04
|
Hello, Template Toolkit's dot notation is almost ready for a CPAN release a plugin for HTML::Template. I would like to see HTML::Template support plugins directly, but I intend to release HTML::Template::Pluggable as a sub-class so the functionality can be publicly available until that time. However, the dot notation still won't work inside of loops without a trivial patch to HTML::Template to remove the hardcoding of the package name in one place: http://rt.cpan.org/NoAuth/Bug.html?id=14037 A preview release is here: http://mark.stosberg.com/perl/HTML-Template-Pluggable-0.01.tar.gz And some of the documentation is below. Special thanks go to Rhesa Rozendaal for collaborating with me on this, and to David Baker, Jason Crome and others for cheering us on. Mark SYNOPSIS use HTML::Template::Pluggable; use HTML::Template::Plugin::Dot; my $t = HTML::Template::Pluggable->new(...); Now you can use chained accessor calls and nested hashrefs as params, and access them with a dot notation. You can even pass basic arguments to the methods. For example, in your code: $t->param( my_complex_struct => $struct ); And then in your template you can reference specific values in the structure: my_complex_struct.key.obj.accessor('hash') my_complex_struct.other_key DESCRIPTION By adding support for this dot notation to HTML::Template, the program- mers job of sending data to the template is easier, and designers have easier to access to more data to display in the template, without learning any more tag syntax. EXAMPLES Class::DBI integration Class::DBI accessors can be used in the template. If the accessor is never called in the template, that data doesn't have to be loaded. In the code: $t->param ( my_row => $class_dbi_obj ); In the template: my_row.last_name DateTime integration DateTime is a great date date formatting module. By using it with this plugin, you can leave the date formatting in the template, where a savvy designer can adjust it. $t->param ( my_date => $dt_obj ); In the template: my_row.strftime('%D'); Of course, if date formatting strings look scary to the designer, you can keep them in the application, or even a database layer to insure consistency in all presentations. ########### Mark -- http://mark.stosberg.com/ |
From: Mark S. <ma...@su...> - 2005-08-04 15:05:31
|
Hello, Here's a patch to add a plugin system and a first plugin for HTML::Template: http://mark.stosberg.com/perl/ht-plugin-dot.patch It's rough, but should serve well enough for a conversation piece. The first part is a lightweight plugin system modeled after the successful one that CGI::Application uses, but simplified significantly more for this. From a user's perspective, its presence has no visible effect, and should have a negligible impact on performance (because it does extremely little). There is only one place to hook into the code so far, in param(). I'll provide an example of what this is good for below. While there are several sub classes of HTML::Template, what if you want to use functionality from more than sub class? If they both override param in different ways, it's not possible. The plugin system fixes that. Each plugin can add extra functionality to param(), while cooperating with other plugins. I believe, for example, that this plugin will work fine with HTML::Template::Set without any code changes to it, although it also overloads param(), which my plugin also wants to use. If I had released my functionality as standard sub-class, these two would conflict. ( HTML::Template::Set would allow you to have a header in an include file, while the designer can set the title to display there from the parent file: <TMPL_SET NAME="title">Hi Mom!</TMPL_SET> ) For a first plugin, I have included in the patch HTML::Template::Plugin::Dot, which adds part of Template Toolkit's magic dot notation. This allows dots in a tmpl_var to represent chained method calls or a deeply nested hashref. Because we check for a literal param with dots in it first, it is backwards compatible with current H::T behavior. It's dead simple to use. Just: use HTML::Template; use HTML::Template::Plugin::Dot; Then you can put in your template my_hash.deeply_nested.sage_brush An pull out the right value from here: my_hash => { deeply_nested => { sage_brush => 'You Found Me!' } } Likewise, you could set a param to be a Class::DBI (or compatible) object my_row => $class_dbi_row And then in your template you can call several methods on that object: my_row.num_forks my_row.num_lawsuits And so forth. Looking forward, my plugin system needs some refinement to be polished. Hooks in new() and output() would be useful, and my param() hook could be polished. I welcome coding collaborators on this project. To that end, I have set up a public darcs repository. I have used H::T 2.7 has my base and added my patches to it. To hack on it, just: darcs get http://mark.stosberg.com/darcs_hive/ht-dot/ cd ht-dot # hack.. darcs record # Send me a darcs patch via e-mail. darcs send You can get a darcs binary from http://www.darcs.net/ Thanks! Mark -- http://mark.stosberg.com/ |
From: Mark S. <ma...@su...> - 2005-08-04 14:43:03
|
As I worked on a new plugin system for HTML::Template [0], I recycled code from CGI::Application's new plugin system [1]. As I reflected on this, CGI::Application has developed a nice plugin system which is easily re-usable on it's own. It is most similar to Class::Trigger [2], but I think the CGI::App solution is more advanced for these reasons: - We look up the inheritance tree for more callbacks to execute - We allow arguments to be passed into the callbacks, customizing how each callback can work, and creating clearer, more explicit syntax than passing through the object. - We have a specific callback ordering, and we expect to soon solve the problem of making this ordering to be sufficiently flexible to address most plugin needs. - Class::Trigger requires your object be implemented as blessed hashref (Gasp!). We could solve this in our implementation by adding a method for 'installed_callbacks()', which could be trivially overridden if the callbacks needed to be stored in the object a different way. So I would like to move CGI::App's plugin system into it's own module, which wouldn't change anything from a user's perspective, except perhaps where the related documentation is located. I could see what we have possibly being merged into a future enhanced version of Class::Trigger, which CGI::App would then have it's own plugin for, to keep compatibility with the names we've already established. 0. http://use.perl.org/~markjugg/journal/26089 1. http://www.cgi-app.org/?Plugins 2. http://search.cpan.org/perldoc?Class::Trigger Collaborators welcome! Let's keep discussing it on the CGI::App mailing list and #cgiapp on irc.perl.org. Mark -- . . . . . . . . . . . . . . . . . . . . . . . . . . . Mark Stosberg Principal Developer ma...@su... Summersault, LLC 765-939-9301 ext 202 database driven websites . . . . . http://www.summersault.com/ . . . . . . . . |