html-template-users Mailing List for HTML::Template (Page 25)
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: Jonathan L. <dat...@gm...> - 2005-12-02 03:04:11
|
Requiring that all loops be handled by iterating through lists of hashes leads to a lot of extra work on the script writer's end, and results in the template writer having rather inflexible data to work with. I'd like to propose a more flexible alternative, which ought to be usable in addition to the current approach: Allow the script writer to pass ordinary lists to a template. Allow the template writer to access them using a modified version of <TMPL_LOOP>: <TMPL_LOOP> <!-- that's right; no loop control variable is given. --> <TMPL_VAR list1> <!-- list1 is an ordinary list that got passed to the template. --> <TMPL_VAR list2> <!-- list2 is another such list. --> </TMPL_LOOP> This loop construct would display the first elements of list1 and list2 on its first pass, the second elements of each list on its second pass, and so on until it exhausts one of the lists (at which point it stops). Without a loop control variable, any variable could be used within the loop, not just list-like variables. So you could do something like: <ul> <TMPL_LOOP> <li><TMPL_VAR value_set>: <TMPL_VAR count_distribution> out of <TMPL_VAR sum_of_counts></li> </TMPL_LOOP> </ul> Given: @value_set =3D (2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12); @count_distribution =3D (1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1); $sum_of_counts =3D 36; This would produce: <ul> <li>2: 1 out of 36</li> <li>3: 2 out of 36</li> <li>4: 3 out of 36</li> <li>5: 4 out of 36</li> <li>6: 5 out of 36</li> <li>7: 6 out of 36</li> <li>8: 5 out of 36</li> <li>9: 4 out of 36</li> <li>10: 3 out of 36</li> <li>11: 2 out of 36</li> <li>12: 1 out of 36</li> </ul> The only restriction would be that ordinary lists can only be used within a TMPL_LOOP. To me, this seems a lot more intuitive (on both ends of the design) than the current approach, where the script writer would have to say something like: @loop =3D ( {value_set =3D> 2, count_distribution =3D> 1, sum_of_counts =3D> 36 }, {value_set =3D> 3, count_distribution =3D> 2, sum_of_counts =3D> 36 }, {value_set =3D> 4, count_distribution =3D> 3, sum_of_counts =3D> 36 }, {value_set =3D> 5, count_distribution =3D> 4, sum_of_counts =3D> 36 }, {value_set =3D> 6, count_distribution =3D> 5, sum_of_counts =3D> 36 }, {value_set =3D> 7, count_distribution =3D> 6, sum_of_counts =3D> 36 }, {value_set =3D> 8, count_distribution =3D> 5, sum_of_counts =3D> 36 }, {value_set =3D> 9, count_distribution =3D> 4, sum_of_counts =3D> 36 }, {value_set =3D> 10, count_distribution =3D> 3, sum_of_counts =3D> 36 }, {value_set =3D> 11, count_distribution =3D> 2, sum_of_counts =3D> 36 }, {value_set =3D> 12, count_distribution =3D> 1, sum_of_counts =3D> 36 }, ) Bulky and painful. - You might even have it handle lists of lists, by nesting TMPL_LOOPs: <table> <TMPL_LOOP> <tr><TMPL_LOOP><td><TMPL_VAR count></td></TMPL_LOOP></tr> </TMPL_LOOP> </table> and @count =3D ([2, 3, 4, 5, 6, 7], [3, 4, 5, 6, 7, 8], [4, 5, 6, 7, 8, 9], [5, 6, 7, 8, 9, 10], [6, 7, 8, 9, 10, 11], [7, 8, 9, 10, 11, 12]); produces: <table> <tr><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td></tr> <tr><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td><td>8</td></tr> <tr><td>4</td><td>5</td><td>6</td><td>7</td><td>8</td><td>9</td></tr> <tr><td>5</td><td>6</td><td>7</td><td>8</td><td>9</td><td>10</td></tr> <tr><td>6</td><td>7</td><td>8</td><td>9</td><td>10</td><td>11</td></tr> <tr><td>7</td><td>8</td><td>9</td><td>10</td><td>11</td><td>12</td></tr> </table> lists of lists of lists would also be possible, but the usefulness of lists of lists is already getting close to marginal. - I have an idea that would allow script writers to load hashes into a template as well; but IMHO that's not nearly as useful as loading ordinary list variables. -- Jonathan "Dataweaver" Lang |
From: Boon C. <was...@ya...> - 2005-12-02 00:26:41
|
It might be difficult to do for multilevel nested data structure, but I think having support for one of the most common data structure, array of hash, is a good start, because array of hash mirrors the structure of a resultset coming back from a DB query. Currently we can use tmpl_loop to loop through the array elements (or thinking in terms of DB, the rows), so that's taken care of. What's missing is a way to get the hash keys, so maybe there can be a contextual var that gives you the hash keys (from the DB perspective, the columns or fields), as in __ColumnList__ or something that you can loop through with. Sorry I am just thinking out loud here, as I don't know enough about HTML::Template internals enough to know that's possible or makes sense. - boon Mathew Robertson <mat...@ne...> wrote: I agree too - what I was trying to say was that, I dont think it is even technically possible to do it generically. Can you think of an example of how to do it generically? If you can, I could quite easily modify my H::T version to support this functionality. Mat Boon Chew wrote: I agree with you that the coupling cannot be totally avoided, but being able to deal with template var generically in the presentation layer is very useful in avoiding having to create duplicate html code that are doing exactly the same thing. - boon Mathew Robertson <mat...@ne...> wrote: The coupling of a template to the template-params is something that cant really be avoided - at some point the template designer has to have some understanding of what template-variables are being generated. Since you are the developer creating the code that generates the template-variables, it is your responsibility to "publish" the variable names and their meaning, it is not up to the template designer to "figure out" what they are and what they represent. That said, there is a justified argument for wanting something like a <TMPL_DUMP some_var> which writes a dumped-block into the target page. Mathew PS. I maintain a version of H::T which supports sub-classing so that you can create your own TMPL tags, see: http://members.optusnet.com.au/~mathew Boon Chew wrote: I want a way to quickly display all the info in a var - a Dumper output if you will. But more than that, like in some other server-side language, you can query the column lists (or hash keys) and loop through those and use a piece of generic code when all you intend to do is to display everything in the var. Imagine yourself wanting to output all the info in a reference to an array of hashes (which essentially mimics a database table), the HTML code can really be made the same if a construct is available to loop through things. The tight coupling of knowledge between what's being sent from the perl code and the HTML can be avoided, that's the whole point of the design of the template module (vs Mason where you mingle Perl code with display code) right? It just seems ugly when I have to tell a designer to go look at the perl file to see what he is getting in the var. He should be able to find that out from some sensible constructs. - boon Mathew Robertson <mat...@ne...> wrote: It sounds like you need a tool which simply dumps the template variable names (ie: using the $ht->params() function), rather than some special mode to H::T Mathew Boon Chew wrote: Ya sorry, that's what I meant. Right now I am working on some site code, and the designer sometimes have to come to me for stuff because he doesn't always know what hash keys I am passing to him (say sometimes I might add a new one, sometimes he mistype one, etc.). The whole point of doing this template separation is to decouple things, but if the designer can only figure out what's being passed into the template by looking at the module code, it kinda defeats the whole purpose. It would be such great convenience to be able to dump the whole thing on the HTML with a call like this: <tmpl_var story_loop> or <tmpl_loop story_loop> <column_var> <-- outputs all keys here </tmpl_loop> Carl Franks <fir...@gm...> wrote: > e.g. > > > a TMPL_LOOP doesn't take a hash, it takes an array-ref of hash-refs that would be my @loop = ( {name => 'a'}, {name => 'b'}, ); $tmpl->param( students => \@loop ); If you knew that already, give an example of what sort of data you want to put in, and what you want the HTML to look like. Cheers, Carl ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_idv37&alloc_id865&op=click _______________________________________________ Html-template-users mailing list Htm...@li... https://lists.sourceforge.net/lists/listinfo/html-template-users --------------------------------- Yahoo! Personals Single? There's someone we'd like you to meet. Lots of someones, actually. Yahoo! Personals --------------------------------- Yahoo! DSL Something to write home about. Just $16.99/mo. or less --------------------------------- Yahoo! DSL Something to write home about. Just $16.99/mo. or less --------------------------------- Yahoo! Personals Let fate take it's course directly to your email. See who's waiting for you Yahoo! Personals |
From: Mathew R. <mat...@ne...> - 2005-12-02 00:06:05
|
I agree too - what I was trying to say was that, I dont think it is even = technically possible to do it generically. Can you think of an example of how to do it generically? If you can, I=20 could quite easily modify my H::T version to support this functionality. Mat Boon Chew wrote: > > I agree with you that the coupling cannot be totally avoided, but=20 > being able to deal with template var generically in the presentation=20 > layer is very useful in avoiding having to create duplicate html code=20 > that are doing exactly the same thing.=20 > > - boon > > */Mathew Robertson <mat...@ne...>/* wrote: > > The coupling of a template to the template-params is something > that cant really be avoided - at some point the template designer > has to have some understanding of what template-variables are > being generated. Since you are the developer creating the code > that generates the template-variables, it is your responsibility > to "publish" the variable names and their meaning, it is not up to > the template designer to "figure out" what they are and what they > represent. > > That said, there is a justified argument for wanting something > like a <TMPL_DUMP some_var> which writes a dumped-block into the > target page. > > Mathew > > PS. I maintain a version of H::T which supports sub-classing so > that you can create your own TMPL tags, see: > http://members.optusnet.com.au/~mathew > > > Boon Chew wrote: > >> I want a way to quickly display all the info in a var - a Dumper >> output if you will. But more than that, like in some other >> server-side language, you can query the column lists (or hash >> keys) and loop through those and use a piece of generic code when >> all you intend to do is to display everything in the var. >> >> Imagine yourself wanting to output all the info in a reference to >> an array of hashes (which essentially mimics a database table), >> the HTML code can really be made the same if a construct is >> available to loop through things. >> >> The tight coupling of knowledge between what's being sent from >> the perl code and the HTML can be avoided, that's the whole point >> of the design of the template module (vs Mason where you mingle >> Perl code with display code) right? It just seems ugly when I >> have to tell a designer to go look at the perl file to see what >> he is getting in the var. He should be able to find that out >> from some sensible constructs. >> >> - boon >> >> */Mathew Robertson <mat...@ne...>/* wrote: >> >> It sounds like you need a tool which simply dumps the >> template variable names (ie: using the $ht->params() >> function), rather than some special mode to H::T >> >> Mathew >> >> Boon Chew wrote: >> >>> Ya sorry, that's what I meant. >>> >>> Right now I am working on some site code, and the designer >>> sometimes have to come to me for stuff because he doesn't >>> always know what hash keys I am passing to him (say >>> sometimes I might add a new one, sometimes he mistype one, >>> etc.). The whole point of doing this template separation is >>> to decouple things, but if the designer can only figure out >>> what's being passed into the template by looking at the >>> module code, it kinda defeats the whole purpose. >>> >>> It would be such great convenience to be able to dump the >>> whole thing on the HTML with a call like this: >>> >>> <tmpl_var story_loop> >>> >>> or >>> >>> <tmpl_loop story_loop> >>> <column_var> <-- outputs all keys here >>> </tmpl_loop> >>> >>> */Carl Franks <fir...@gm...>/* wrote: >>> >>> > e.g. >>> > >>> > >>> > >>> >>> a TMPL_LOOP doesn't take a hash, it takes an array-ref >>> of hash-refs >>> that would be >>> >>> my @loop =3D ( >>> {name =3D> 'a'}, >>> {name =3D> 'b'}, >>> ); >>> >>> $tmpl->param( students =3D> \@loop ); >>> >>> If you knew that already, give an example of what sort >>> of data you >>> want to put in, and what you want the HTML to look like. >>> >>> Cheers, >>> Carl >>> >>> >>> ------------------------------------------------------- >>> This SF.net email is sponsored by: Splunk Inc. Do you >>> grep through log files >>> for problems? Stop! Download the new AJAX search engine >>> that makes >>> searching your log files as easy as surfing the web. >>> DOWNLOAD SPLUNK! >>> http://ads.osdn.com/?ad_idv37&alloc_id=16865&op=3Dclick >>> _______________________________________________ >>> Html-template-users mailing list >>> Htm...@li... >>> https://lists.sourceforge.net/lists/listinfo/html-templat= e-users >>> >>> >>> -------------------------------------------------------------= ----------- >>> *Yahoo! Personals* >>> Single? There's someone we'd like you to meet. >>> Lots of someones, actually. Yahoo! Personals >>> <http://us.rd.yahoo.com/evt=3D36108/*http://personals.yahoo.c= om%20> >> >> >> >> ------------------------------------------------------------------= ------ >> Yahoo! DSL >> <http://pa.yahoo.com/*http://us.rd.yahoo.com/evt=3D37474/*http://p= romo.yahoo.com/broadband/%20> >> Something to write home about. Just $16.99/mo. or less=20 > > > -----------------------------------------------------------------------= - > Yahoo! DSL=20 > <http://pa.yahoo.com/*http://us.rd.yahoo.com/evt=3D37474/*http://promo.= yahoo.com/broadband/%20>=20 > Something to write home about. Just $16.99/mo. or less=20 |
From: Jonathan L. <dat...@gm...> - 2005-12-01 23:24:57
|
> PS. I maintain a version of H::T which supports sub-classing so that you > can create your own TMPL tags, see: > http://members.optusnet.com.au/~mathew Nice, except that I can't extract it from the computer that I'm at (grumble, WinXP, grumble, public library computer, grumble). Could someone provide Mathew's version, uncompressed, so that I can look it over? -- Jonathan "Dataweaver" Lang |
From: Boon C. <was...@ya...> - 2005-12-01 23:04:59
|
I agree with you that the coupling cannot be totally avoided, but being able to deal with template var generically in the presentation layer is very useful in avoiding having to create duplicate html code that are doing exactly the same thing. - boon Mathew Robertson <mat...@ne...> wrote: The coupling of a template to the template-params is something that cant really be avoided - at some point the template designer has to have some understanding of what template-variables are being generated. Since you are the developer creating the code that generates the template-variables, it is your responsibility to "publish" the variable names and their meaning, it is not up to the template designer to "figure out" what they are and what they represent. That said, there is a justified argument for wanting something like a <TMPL_DUMP some_var> which writes a dumped-block into the target page. Mathew PS. I maintain a version of H::T which supports sub-classing so that you can create your own TMPL tags, see: http://members.optusnet.com.au/~mathew Boon Chew wrote: I want a way to quickly display all the info in a var - a Dumper output if you will. But more than that, like in some other server-side language, you can query the column lists (or hash keys) and loop through those and use a piece of generic code when all you intend to do is to display everything in the var. Imagine yourself wanting to output all the info in a reference to an array of hashes (which essentially mimics a database table), the HTML code can really be made the same if a construct is available to loop through things. The tight coupling of knowledge between what's being sent from the perl code and the HTML can be avoided, that's the whole point of the design of the template module (vs Mason where you mingle Perl code with display code) right? It just seems ugly when I have to tell a designer to go look at the perl file to see what he is getting in the var. He should be able to find that out from some sensible constructs. - boon Mathew Robertson <mat...@ne...> wrote: It sounds like you need a tool which simply dumps the template variable names (ie: using the $ht->params() function), rather than some special mode to H::T Mathew Boon Chew wrote: Ya sorry, that's what I meant. Right now I am working on some site code, and the designer sometimes have to come to me for stuff because he doesn't always know what hash keys I am passing to him (say sometimes I might add a new one, sometimes he mistype one, etc.). The whole point of doing this template separation is to decouple things, but if the designer can only figure out what's being passed into the template by looking at the module code, it kinda defeats the whole purpose. It would be such great convenience to be able to dump the whole thing on the HTML with a call like this: <tmpl_var story_loop> or <tmpl_loop story_loop> <column_var> <-- outputs all keys here </tmpl_loop> Carl Franks <fir...@gm...> wrote: > e.g. > > > a TMPL_LOOP doesn't take a hash, it takes an array-ref of hash-refs that would be my @loop = ( {name => 'a'}, {name => 'b'}, ); $tmpl->param( students => \@loop ); If you knew that already, give an example of what sort of data you want to put in, and what you want the HTML to look like. Cheers, Carl ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_idv37&alloc_id865&op=click _______________________________________________ Html-template-users mailing list Htm...@li... https://lists.sourceforge.net/lists/listinfo/html-template-users --------------------------------- Yahoo! Personals Single? There's someone we'd like you to meet. Lots of someones, actually. Yahoo! Personals --------------------------------- Yahoo! DSL Something to write home about. Just $16.99/mo. or less --------------------------------- Yahoo! DSL Something to write home about. Just $16.99/mo. or less |
From: Mathew R. <mat...@ne...> - 2005-12-01 22:44:07
|
The coupling of a template to the template-params is something that cant = really be avoided - at some point the template designer has to have some = understanding of what template-variables are being generated. Since you = are the developer creating the code that generates the=20 template-variables, it is your responsibility to "publish" the variable=20 names and their meaning, it is not up to the template designer to=20 "figure out" what they are and what they represent. That said, there is a justified argument for wanting something like a=20 <TMPL_DUMP some_var> which writes a dumped-block into the target page. Mathew PS. I maintain a version of H::T which supports sub-classing so that you = can create your own TMPL tags, see: http://members.optusnet.com.au/~mathe= w Boon Chew wrote: > I want a way to quickly display all the info in a var - a Dumper=20 > output if you will. But more than that, like in some other=20 > server-side language, you can query the column lists (or hash keys)=20 > and loop through those and use a piece of generic code when all you=20 > intend to do is to display everything in the var. > > Imagine yourself wanting to output all the info in a reference to an=20 > array of hashes (which essentially mimics a database table), the HTML=20 > code can really be made the same if a construct is available to loop=20 > through things. > > The tight coupling of knowledge between what's being sent from the=20 > perl code and the HTML can be avoided, that's the whole point of the=20 > design of the template module (vs Mason where you mingle Perl code=20 > with display code) right? It just seems ugly when I have to tell a=20 > designer to go look at the perl file to see what he is getting in the=20 > var. He should be able to find that out from some sensible constructs.= > > - boon > > */Mathew Robertson <mat...@ne...>/* wrote: > > It sounds like you need a tool which simply dumps the template > variable names (ie: using the $ht->params() function), rather than > some special mode to H::T > > Mathew > > Boon Chew wrote: > >> Ya sorry, that's what I meant. >> >> Right now I am working on some site code, and the designer >> sometimes have to come to me for stuff because he doesn't always >> know what hash keys I am passing to him (say sometimes I might >> add a new one, sometimes he mistype one, etc.). The whole point >> of doing this template separation is to decouple things, but if >> the designer can only figure out what's being passed into the >> template by looking at the module code, it kinda defeats the >> whole purpose. >> >> It would be such great convenience to be able to dump the whole >> thing on the HTML with a call like this: >> >> <tmpl_var story_loop> >> >> or >> >> <tmpl_loop story_loop> >> <column_var> <-- outputs all keys here >> </tmpl_loop> >> >> */Carl Franks <fir...@gm...>/* wrote: >> >> > e.g. >> > >> > >> > >> >> a TMPL_LOOP doesn't take a hash, it takes an array-ref of >> hash-refs >> that would be >> >> my @loop =3D ( >> {name =3D> 'a'}, >> {name =3D> 'b'}, >> ); >> >> $tmpl->param( students =3D> \@loop ); >> >> If you knew that already, give an example of what sort of >> data you >> want to put in, and what you want the HTML to look like. >> >> Cheers, >> Carl >> >> >> ------------------------------------------------------- >> This SF.net email is sponsored by: Splunk Inc. Do you grep >> through log files >> for problems? Stop! Download the new AJAX search engine that >> makes >> searching your log files as easy as surfing the web. DOWNLOAD >> SPLUNK! >> http://ads.osdn.com/?ad_idv37&alloc_id=16865&op=3Dclick >> _______________________________________________ >> Html-template-users mailing list >> Htm...@li... >> https://lists.sourceforge.net/lists/listinfo/html-template-use= rs >> >> >> ------------------------------------------------------------------= ------ >> *Yahoo! Personals* >> Single? There's someone we'd like you to meet. >> Lots of someones, actually. Yahoo! Personals >> <http://us.rd.yahoo.com/evt=3D36108/*http://personals.yahoo.com%20= >=20 > > > -----------------------------------------------------------------------= - > Yahoo! DSL=20 > <http://pa.yahoo.com/*http://us.rd.yahoo.com/evt=3D37474/*http://promo.= yahoo.com/broadband/%20>=20 > Something to write home about. Just $16.99/mo. or less=20 |
From: Mathew R. <mat...@ne...> - 2005-12-01 22:30:21
|
This is easiest achieved if you use H::T::Expr, eg: <TMPL_LOOP some_loop> <TMPL_IF EXPR="__counter__ < 50"> ... </TMPL_IF> </TMPL_LOOP> Mathew Boon Chew wrote: > Another newbie question about HTML::Template. > > Is there a way to output only a subset of a loop variable? > For instance, let's say I have a template var that is a reference to > array of hashes of X elements (essentially a recordset with X rows of > data), is it possible to output just the first N rows while looping > through it? > > e.g. > > <tmpl_loop employee_loop> > <tmpl_var lastname>, <tmpl_var firstname> <-- I just want the > first N employees > </tmpl_loop> > > I guess the main problem I am having is that I am not able to set any > loop counter in the template to stop it at the right time (which is > probably a design choice after all). > > - boon > > > > ------------------------------------------------------------------------ > Yahoo! DSL > <http://pa.yahoo.com/*http://us.rd.yahoo.com/evt=37474/*http://promo.yahoo.com/broadband/%20> > Something to write home about. Just $16.99/mo. or less |
From: Boon C. <was...@ya...> - 2005-12-01 22:15:44
|
Another newbie question about HTML::Template. Is there a way to output only a subset of a loop variable? For instance, let's say I have a template var that is a reference to array of hashes of X elements (essentially a recordset with X rows of data), is it possible to output just the first N rows while looping through it? e.g. <tmpl_loop employee_loop> <tmpl_var lastname>, <tmpl_var firstname> <-- I just want the first N employees </tmpl_loop> I guess the main problem I am having is that I am not able to set any loop counter in the template to stop it at the right time (which is probably a design choice after all). - boon --------------------------------- Yahoo! DSL Something to write home about. Just $16.99/mo. or less |
From: Boon C. <was...@ya...> - 2005-12-01 22:10:38
|
I want a way to quickly display all the info in a var - a Dumper output if you will. But more than that, like in some other server-side language, you can query the column lists (or hash keys) and loop through those and use a piece of generic code when all you intend to do is to display everything in the var. Imagine yourself wanting to output all the info in a reference to an array of hashes (which essentially mimics a database table), the HTML code can really be made the same if a construct is available to loop through things. The tight coupling of knowledge between what's being sent from the perl code and the HTML can be avoided, that's the whole point of the design of the template module (vs Mason where you mingle Perl code with display code) right? It just seems ugly when I have to tell a designer to go look at the perl file to see what he is getting in the var. He should be able to find that out from some sensible constructs. - boon Mathew Robertson <mat...@ne...> wrote: It sounds like you need a tool which simply dumps the template variable names (ie: using the $ht->params() function), rather than some special mode to H::T Mathew Boon Chew wrote: Ya sorry, that's what I meant. Right now I am working on some site code, and the designer sometimes have to come to me for stuff because he doesn't always know what hash keys I am passing to him (say sometimes I might add a new one, sometimes he mistype one, etc.). The whole point of doing this template separation is to decouple things, but if the designer can only figure out what's being passed into the template by looking at the module code, it kinda defeats the whole purpose. It would be such great convenience to be able to dump the whole thing on the HTML with a call like this: <tmpl_var story_loop> or <tmpl_loop story_loop> <column_var> <-- outputs all keys here </tmpl_loop> Carl Franks <fir...@gm...> wrote: > e.g. > > > a TMPL_LOOP doesn't take a hash, it takes an array-ref of hash-refs that would be my @loop = ( {name => 'a'}, {name => 'b'}, ); $tmpl->param( students => \@loop ); If you knew that already, give an example of what sort of data you want to put in, and what you want the HTML to look like. Cheers, Carl ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_idv37&alloc_id865&op=click _______________________________________________ Html-template-users mailing list Htm...@li... https://lists.sourceforge.net/lists/listinfo/html-template-users --------------------------------- Yahoo! Personals Single? There's someone we'd like you to meet. Lots of someones, actually. Yahoo! Personals --------------------------------- Yahoo! DSL Something to write home about. Just $16.99/mo. or less |
From: Mathew R. <mat...@ne...> - 2005-12-01 21:59:16
|
It sounds like you need a tool which simply dumps the template variable=20 names (ie: using the $ht->params() function), rather than some special=20 mode to H::T Mathew Boon Chew wrote: > Ya sorry, that's what I meant. > > Right now I am working on some site code, and the designer sometimes=20 > have to come to me for stuff because he doesn't always know what hash=20 > keys I am passing to him (say sometimes I might add a new one,=20 > sometimes he mistype one, etc.). The whole point of doing this=20 > template separation is to decouple things, but if the designer can=20 > only figure out what's being passed into the template by looking at=20 > the module code, it kinda defeats the whole purpose. > > It would be such great convenience to be able to dump the whole thing=20 > on the HTML with a call like this: > > <tmpl_var story_loop> > > or > > <tmpl_loop story_loop> > <column_var> <-- outputs all keys here > </tmpl_loop> > > */Carl Franks <fir...@gm...>/* wrote: > > > e.g. > > > > > > > > a TMPL_LOOP doesn't take a hash, it takes an array-ref of hash-refs= > that would be > > my @loop =3D ( > {name =3D> 'a'}, > {name =3D> 'b'}, > ); > > $tmpl->param( students =3D> \@loop ); > > If you knew that already, give an example of what sort of data you > want to put in, and what you want the HTML to look like. > > Cheers, > Carl > > > ------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. Do you grep through > log files > for problems? Stop! Download the new AJAX search engine that makes > searching your log files as easy as surfing the web. DOWNLOAD SPLUN= K! > http://ads.osdn.com/?ad_idv37&alloc_id=16865&op=3Dclick > _______________________________________________ > Html-template-users mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/html-template-users > > > -----------------------------------------------------------------------= - > *Yahoo! Personals* > Single? There's someone we'd like you to meet. > Lots of someones, actually. Yahoo! Personals=20 > <http://us.rd.yahoo.com/evt=3D36108/*http://personals.yahoo.com%20>=20 |
From: Mathew R. <mat...@ne...> - 2005-12-01 21:55:11
|
>>>Since there wasn't any new release for more than one year I would also like >>>to ask you whether this package is still maintanted. >>> >>> >>It's still maintained, although I'm too busy to spend a lot of time on >>it right now. Maybe next year... >> >> > >But it would still be nice if there would be a new release. With some >bugfixes for example. It does not need to have all new features. And >it would show that this module is still maintained. > That is a bit harsh... And if Sam was to put out a release with bugfixes, what would it contain? You have the source code to H::T, you could always do produce a release yourself - Sam may even take the to code to make it official... Also, there are a few of us here that maintain modified versions of H::T, each of which enhance H::T in some way - you could always choose to use those instead. Mathew |
From: Boon C. <was...@ya...> - 2005-12-01 20:16:03
|
Ya sorry, that's what I meant. Right now I am working on some site code, and the designer sometimes have to come to me for stuff because he doesn't always know what hash keys I am passing to him (say sometimes I might add a new one, sometimes he mistype one, etc.). The whole point of doing this template separation is to decouple things, but if the designer can only figure out what's being passed into the template by looking at the module code, it kinda defeats the whole purpose. It would be such great convenience to be able to dump the whole thing on the HTML with a call like this: <tmpl_var story_loop> or <tmpl_loop story_loop> <column_var> <-- outputs all keys here </tmpl_loop> Carl Franks <fir...@gm...> wrote: > e.g. > > > a TMPL_LOOP doesn't take a hash, it takes an array-ref of hash-refs that would be my @loop = ( {name => 'a'}, {name => 'b'}, ); $tmpl->param( students => \@loop ); If you knew that already, give an example of what sort of data you want to put in, and what you want the HTML to look like. Cheers, Carl ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_idv37&alloc_id865&op=click _______________________________________________ Html-template-users mailing list Htm...@li... https://lists.sourceforge.net/lists/listinfo/html-template-users --------------------------------- Yahoo! Personals Single? There's someone we'd like you to meet. Lots of someones, actually. Yahoo! Personals |
From: Carl F. <fir...@gm...> - 2005-12-01 20:03:10
|
> e.g. > <tmpl_loop students> > <tmpl_var name> > </tmpl_loop> a TMPL_LOOP doesn't take a hash, it takes an array-ref of hash-refs that would be my @loop =3D ( {name =3D> 'a'}, {name =3D> 'b'}, ); $tmpl->param( students =3D> \@loop ); If you knew that already, give an example of what sort of data you want to put in, and what you want the HTML to look like. Cheers, Carl |
From: Boon C. <was...@ya...> - 2005-12-01 19:41:38
|
I can't find a way in the doc to loop through hash without knowing the keys in the hash. If this feature is not available, I think the fact that the template has to always such intimiate knowledge of what's being passed to it is not always a good thing, it also makes it impossible to just dump out all the data on the HTML end with a simple statement. e.g. <tmpl_loop students> <tmpl_var name> </tmpl_loop> --------------------------------- Yahoo! Music Unlimited - Access over 1 million songs. Try it free. |
From: Mitar <mm...@gm...> - 2005-12-01 09:22:17
|
Hi! On 11/30/05, Sam Tregar <sa...@tr...> wrote: > On Tue, 29 Nov 2005, Jozef Kosoru wrote: > > Since there wasn't any new release for more than one year I would also = like > > to ask you whether this package is still maintanted. > > It's still maintained, although I'm too busy to spend a lot of time on > it right now. Maybe next year... But it would still be nice if there would be a new release. With some bugfixes for example. It does not need to have all new features. And it would show that this module is still maintained. Mitar |
From: Jozef K. <zy...@ui...> - 2005-11-30 21:25:40
|
Hello, thanks for the answer. On Tue, Nov 29, 2005 at 19:01:12 -0500, Sam Tregar wrote: > > my $rTmpl1 = HTML::Template->new(filename => $htmlTemplate, cache => 1); > > my $rTmpl2 = HTML::Template->new(filename => $htmlTemplate, cache => 1); > > Ok, that won't work. The cache is going to hand you back two > references to the same object. Try this instead: > > use Storable qw(dclone); > my $rTmpl1 = HTML::Template->new(filename => $htmlTemplate, cache => 1); > my $rTmpl2 = dclone($rTmpl2); > > Or, possibly faster: > > use Clone qw(clone); > my $rTmpl1 = HTML::Template->new(filename => $htmlTemplate, cache => 1); > my $rTmpl2 = clone($rTmpl2); Yes, great! That works. But this was simple and rather contrived example. In practice it's impossible (or at least impractical) to make as many clones of the same template object as needed before thay are used. I would therefore like to introduce a new cache option "cloned_cache" which will use cached data only as a template for making clones. I'll try to implement it myself but as I've looked to sources - it won't be that easy :) But I think this strategy must already be used for the "shared_cache", isn't it? Because in that case many processes may use the cached data in the same time. Regards, Jozef -- jozef kosoru http://zyzstar.kosoru.com |
From: Sam T. <sa...@tr...> - 2005-11-30 00:01:17
|
On Tue, 29 Nov 2005, Jozef Kosoru wrote: > Since there wasn't any new release for more than one year I would also like > to ask you whether this package is still maintanted. It's still maintained, although I'm too busy to spend a lot of time on it right now. Maybe next year... > Regarding this bug. Could you help me somehow, please? I've tried to fix > it myself, but the code is a bit too complex. Thank you. Hmmm, alright, let's see. > my $rTmpl1 = HTML::Template->new(filename => $htmlTemplate, cache => 1); > my $rTmpl2 = HTML::Template->new(filename => $htmlTemplate, cache => 1); Ok, that won't work. The cache is going to hand you back two references to the same object. Try this instead: use Storable qw(dclone); my $rTmpl1 = HTML::Template->new(filename => $htmlTemplate, cache => 1); my $rTmpl2 = dclone($rTmpl2); Or, possibly faster: use Clone qw(clone); my $rTmpl1 = HTML::Template->new(filename => $htmlTemplate, cache => 1); my $rTmpl2 = clone($rTmpl2); -sam |
From: Jozef K. <zy...@ui...> - 2005-11-28 19:34:14
|
Hello HTML::Template developers and users, I would like to report a bug regarding cache feature and template objects using the same template file. Here is the Test-Case: * /opt/Perl/Playground/template.tmp ---------------------------------------------------------------------------- <TMPL_VAR NAME="TITLE"> <TMPL_VAR NAME="CONTENT"> ---------------------------------------------------------------------------- * /opt/Perl/Playground/HtmlTmplHandler.tmpl ---------------------------------------------------------------------------- package Playground::HtmlTmplBugHandler; use warnings; use strict; use Apache2::RequestRec (); use HTML::Template (); my $htmlTemplate = '/opt/Perl/Playground/template.tmpl'; sub handler { my $rRequestRec = shift; my $rTmpl1 = HTML::Template->new(filename => $htmlTemplate, cache => 1); my $rTmpl2 = HTML::Template->new(filename => $htmlTemplate, cache => 1); $rTmpl1->param(TITLE => 'Title'); $rTmpl2->param(TITLE => 'Subtitle', CONTENT => 'Content'); $rTmpl1->param(CONTENT => $rTmpl2->output()); # Invalid. Outputs: # Subtitle # Subtitle # Content =begin comment $rTmpl2->param(TITLE => 'Subtitle', CONTENT => 'Content'); $rTmpl1->param(TITLE => 'Title'); $rTmpl1->param(CONTENT => $rTmpl2->output()); # Invalid. Outputs: # Title # Title # Content =cut =begin comment $rTmpl2->param(TITLE => 'Subtitle', CONTENT => 'Content'); $rTmpl1->param(TITLE => 'Title', CONTENT => $rTmpl2->output()); # Correct. Outputs: # Title # Subtitle # Content =cut $rRequestRec->content_type('text/plain'); $rRequestRec->print($rTmpl1->output()); $rRequestRec->rflush(); return Apache2::Const::OK; } 1; ---------------------------------------------------------------------------- * httpd.conf ---------------------------------------------------------------------------- .. <Location /html_template_bug> SetHandler modperl PerlResponseHandler Playground::HtmlTmplBugHandler </Location> .. ---------------------------------------------------------------------------- My configuration: Apache/2.0.54 (Unix) mod_perl/2.0.1 Perl/v5.8.5 HTML::Template v2.7 It seems that there is a global cache for each template file which apparently temporary holds values as well and it doesn't really expect that two or more instances of the same template might be used in the same time. Can anyone help me with this issue? Thank you in advance. Regards, Jozef -- jozef kosoru http://zyzstar.kosoru.com |
From: Brad B. <bm...@ma...> - 2005-11-11 19:34:14
|
On 11/10/05, Senthil Nathan <rs...@gm...> wrote: > Hi Roger, > > Thanks. That works now. > > This is how I did it, > foreach $instance(@diagnosis) > { > my %row =3D ( > line =3D> $instance > ); > push(@diag, \%row); > } > $template->param(dign_loop =3D> \@diag); > > So, Can't we directly pass an array to the template????? Well, you do pass an array (ref) directly to the template. But, as you have shown above, it must be an array of hashes. You could shorten your code a little: $template->param( dign_loop =3D> [ map { line =3D> $_ }, @diagnosis ] ); The problem with accepting an array of strings is you must somehow indicate in the template where each string should be placed. Your expectation seemed to be to use the name of the array as the placeholder. There are a number of reasons why that approach is not a good one (IMO), but the simplest argument is that the method doesn't know the name of the array. ... long story short, make each array element a hash, use the hash key(s) as your placeholder(s), and you're set. Regards, Brad |
From: Senthil N. <rs...@gm...> - 2005-11-10 12:57:40
|
Hi Roger, Thanks. That works now. This is how I did it, foreach $instance(@diagnosis) { my %row =3D ( line =3D> $instance ); push(@diag, \%row); } $template->param(dign_loop =3D> \@diag); So, Can't we directly pass an array to the template????? Thanks rsennat On 11/10/05, Roger Burton West <ro...@fi...> wrote: > > On Thu, Nov 10, 2005 at 05:57:51PM +0530, Senthil Nathan wrote: > > >HTML::Template->output() : fatal error in loop output : HTML::Template : > >Attempt to get nonexistent parameter 'one' - this parameter name > >doesn'tmatch any declarations in the template file : > >(die_on_bad_params set =3D> 1) > >at /usr/cisco/packages/perl/perl-5.8.6 > /lib/site_perl/5.8.6/HTML/Template.pm > >line 2962 at hiGuiResultsBrowser.pm line 334 > > > >Please help me to resolve this. > > I recommend that you reread the documentation, specifically on the > structure of hashes in loops needed by the TMPL_LOOP construct. Hint: > you need a structure of hashes in loops. > > Roger > > > ------------------------------------------------------- > SF.Net email is sponsored by: > Tame your development challenges with Apache's Geronimo App Server. > Download > it for free - -and be entered to win a 42" plasma tv or your very own > Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php > _______________________________________________ > Html-template-users mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/html-template-users > |
From: Roger B. W. <ro...@fi...> - 2005-11-10 12:31:56
|
On Thu, Nov 10, 2005 at 05:57:51PM +0530, Senthil Nathan wrote: >HTML::Template->output() : fatal error in loop output : HTML::Template : >Attempt to get nonexistent parameter 'one' - this parameter name >doesn'tmatch any declarations in the template file : >(die_on_bad_params set => 1) >at /usr/cisco/packages/perl/perl-5.8.6/lib/site_perl/5.8.6/HTML/Template.pm >line 2962 at hiGuiResultsBrowser.pm line 334 > >Please help me to resolve this. I recommend that you reread the documentation, specifically on the structure of hashes in loops needed by the TMPL_LOOP construct. Hint: you need a structure of hashes in loops. Roger |
From: Senthil N. <rs...@gm...> - 2005-11-10 12:28:27
|
Hi All, I am using an HTML::Template module like this, perl script - contains, @diagnosis =3D ( "ONE", "TWO", "THREEE" ); $template->param(dign_loop =3D> \@diagnosis); And template, <TMPL_LOOP NAME=3D"dign_loop"> <TMPL_VAR NAME=3D"diagnosis"> Im not getting the array being displayed. This is the error I get when I run it, HTML::Template->output() : fatal error in loop output : HTML::Template : Attempt to get nonexistent parameter 'one' - this parameter name doesn'tmatch any declarations in the template file : (die_on_bad_params set =3D> 1) at /usr/cisco/packages/perl/perl-5.8.6/lib/site_perl/5.8.6/HTML/Template.pm line 2962 at hiGuiResultsBrowser.pm line 334 Please help me to resolve this. Thanks rsennat |
From: Webmaster Techcode.N. <web...@te...> - 2005-11-09 02:00:46
|
Wouldn't it be great if everyone was writing docs like you do? :) I checked it out - it seems quite interesting. Will give it more thougth = in the morning (it's 3AM ...). Thanks. =20 Indeed, there are a number of solutions that can be implemented. = HTML::Template::Expr with a function callback is probably the easiest = solution. Another possiblility is to use the modified H::T that I use (available = at http://members.optusnet.com.au/~mathew) to create your own TMPL_xxx = syntax. Mathew |
From: Mathew R. <mat...@ne...> - 2005-11-09 01:02:06
|
>>Anyway - I already looked into that. It's what CGI::Application::Framework uses. >>But it's not what I need/want. >> >>That way I can only call some run_mode (method) from current module (one that is outputing >>the template in the first place). I would need to manualy add plugins to each of the module >>(or just in base module). >> >> >>On the other hand, I could write an method in my base module (inherited by others). And implement >>that logic inside of him (require SomeModule, call some_run_mode in it ...). >> >> > >I don't know how much flexibility you need. I have a limited number of >run modes that my templates embed so I just place them in my base class. >I guess you could import them into your namespace or perhaps other list >members have more elegant solutions - I'm sure that there is one though > > Indeed, there are a number of solutions that can be implemented. HTML::Template::Expr with a function callback is probably the easiest solution. Another possiblility is to use the modified H::T that I use (available at http://members.optusnet.com.au/~mathew) to create your own TMPL_xxx syntax. Mathew |
From: Dan H. <dan...@re...> - 2005-11-09 00:16:51
|
On Wed, 2005-11-09 at 12:51, Webmaster Techcode.NET wrote: > MessageNo need to send emails to both me and list (twice) I guess ? > er, ok > > Anyway - I already looked into that. It's what CGI::Application::Framework uses. > But it's not what I need/want. > > That way I can only call some run_mode (method) from current module (one that is outputing > the template in the first place). I would need to manualy add plugins to each of the module > (or just in base module). > > > On the other hand, I could write an method in my base module (inherited by others). And implement > that logic inside of him (require SomeModule, call some_run_mode in it ...). I don't know how much flexibility you need. I have a limited number of run modes that my templates embed so I just place them in my base class. I guess you could import them into your namespace or perhaps other list members have more elegant solutions - I'm sure that there is one though > > > But all that would be similar like this: > > <TMPL_VAR NAME="CGIAPP_EMBED('run_plugin','some_plugin','param1','param')"> > > I was hopping to avoid that ... and make it shorter/simpler as: > > <TMPL_PLUGIN NAME="SomeName(param1, param2)"> Well, you can use a filter to make it whatever you want. I like [% snippet="SomeName(param1, param2)" %] because our designers like to distinguish between template tags and HTML tags, and not using angular brackets make it easier for them > ----- Original Message ----- > From: Dan Horne > To: 'Webmaster Techcode.NET' ; htm...@li... > Sent: Tuesday, November 08, 2005 11:33 PM > Subject: RE: [htmltmpl] Writing an extension for HTML::Template - how to do it? > > > Hi > > Since you're using CGI::App, you should have a look at CGI::Application::Plugin::AnyTemplate - which will allow you to call a run mode with the H::T > > <TMPL_VAR NAME="CGIAPP_embed('some_run_mode', 'param, 'param')"> > > Dan > > -----Original Message----- > From: htm...@li... [mailto:htm...@li...] On Behalf Of Webmaster Techcode.NET > Sent: Wednesday, 9 November 2005 11:16 > To: htm...@li... > Subject: [htmltmpl] Writing an extension for HTML::Template - how to do it? > > > Hello folks! > > Don't know if it's just me or documentation of HTML::Template::Extension isn't good. Eitherway, I can't figure out how to write an extenstion for it, that I need for my project. > > I work with CGI::Application, and I wan't to be able to use (reusable) objects in my templates. > > For instance : > > <tmpl_plugin name="SomeName(param1, param2)"> > > My filter would find SomeName module (Prefix such as MyApp::Plugin::SomeName) make an instance of it and call method - say named run. And place returned value instead of this tag. > > Think of it as another template file that is included but it has some processing ... That way I can create one module/plugin and use it througth whole site/application. > > > If I don't figure this out soon - I will have to give a shot to HTML::Template::Expr and register a function with it (<tmpl_var name="plugin(SomeName, param1, param2)">). > > Thanks. > |