html-template-users Mailing List for HTML::Template (Page 40)
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: Mathew R. <mat...@re...> - 2004-10-07 02:59:22
|
yes - but the question was whether this type of functionality was = suitable to be added as a native capability. Mathew > All those and more can be done using HTML::Template::Expr. >=20 >=20 > > I'd generally agree (mostly) -> the formatting of data is up to the = GUI designer, eg if I want the number 1000000 to contain comma's, I = shouldn't need to get the Perl programmer to generate the a stringified = value caontaining them. > > > > Although, there would need to be alimit on this functionality, as = you might end up making a scripting language just to implement this = extra functionality, in a way which is extensible. In which case, you = might as well just write a Perl module to do the formatting for you. > > > > regards, > > Mathew > > > > ----- Original Message ----- > > From: Bob Diss > > To: htm...@li... > > Sent: Wednesday, October 06, 2004 10:47 PM > > Subject: [htmltmpl] FORMAT=3D enhancement to <TMPL_VAR> construct > > > > > > Greetings! In using HTML::Template I found somewhat limited by the = lack of formatting ability in the template language itself. While I = recognize the need for a separation between coding and layout, I often = found myself making duplicate copies of a value in different formats so = that the layout people would have the version they need. For example: = sometimes they would want the value in all uppercase (for a section = heading), and then again they want it in all lowercase, or sometimes = they want just the first few words (to layout an article teaser). > > > > To do this I implemented an idea I had seen done by a PHP = translation of HTML::Template found at = http://vlib.activefish.com/docs/vlibTemplate.html. The = "FORMAT=3Dsome-value" attribute to the <TMPL_VAR> construct allows the = designer to alter the format of the variable. I implemented several = built-in formatters, including: > > > > FORMAT=3Dlc -- lowercase the value > > FORMAT=3Duc -- uppercase the value > > FORMAT=3Ducfirst -- ucfirst each word in the value > > FORMAT=3Dlcucfirst -- first lowercase the value, then ucfirst = each word > > FORMAT=3Dreverse -- reverse the value > > FORMAT=3Dlength -- output the length of the value > > FORMAT=3D#c -- output the first # characters of the value > > FORMAT=3D#w -- output the first # words of the value > > FORMAT=3D#l -- output the first # lines of the value > > FORMAT=3Dxxxxx -- call the custom formatter 'xxxxx' which was = declared in the 'formatters' hash when the template object was new'ed > > > > Note that FORMAT does not replace ESCAPE. Instead, they happen in = sequence. First, the value is formatted, then it is escaped. > > > > Comments? Thoughts? Suggestions? > > |
From: Peter L. <pe...@pe...> - 2004-10-07 02:17:15
|
All those and more can be done using HTML::Template::Expr. --pete On Thu, 7 Oct 2004, Mathew Robertson wrote: > I'd generally agree (mostly) -> the formatting of data is up to the GUI designer, eg if I want the number 1000000 to contain comma's, I shouldn't need to get the Perl programmer to generate the a stringified value caontaining them. > > Although, there would need to be alimit on this functionality, as you might end up making a scripting language just to implement this extra functionality, in a way which is extensible. In which case, you might as well just write a Perl module to do the formatting for you. > > regards, > Mathew > > ----- Original Message ----- > From: Bob Diss > To: htm...@li... > Sent: Wednesday, October 06, 2004 10:47 PM > Subject: [htmltmpl] FORMAT= enhancement to <TMPL_VAR> construct > > > Greetings! In using HTML::Template I found somewhat limited by the lack of formatting ability in the template language itself. While I recognize the need for a separation between coding and layout, I often found myself making duplicate copies of a value in different formats so that the layout people would have the version they need. For example: sometimes they would want the value in all uppercase (for a section heading), and then again they want it in all lowercase, or sometimes they want just the first few words (to layout an article teaser). > > To do this I implemented an idea I had seen done by a PHP translation of HTML::Template found at http://vlib.activefish.com/docs/vlibTemplate.html. The "FORMAT=some-value" attribute to the <TMPL_VAR> construct allows the designer to alter the format of the variable. I implemented several built-in formatters, including: > > FORMAT=lc -- lowercase the value > FORMAT=uc -- uppercase the value > FORMAT=ucfirst -- ucfirst each word in the value > FORMAT=lcucfirst -- first lowercase the value, then ucfirst each word > FORMAT=reverse -- reverse the value > FORMAT=length -- output the length of the value > FORMAT=#c -- output the first # characters of the value > FORMAT=#w -- output the first # words of the value > FORMAT=#l -- output the first # lines of the value > FORMAT=xxxxx -- call the custom formatter 'xxxxx' which was declared in the 'formatters' hash when the template object was new'ed > > Note that FORMAT does not replace ESCAPE. Instead, they happen in sequence. First, the value is formatted, then it is escaped. > > Comments? Thoughts? Suggestions? > > - Bob Diss > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > |
From: Mathew R. <mat...@re...> - 2004-10-07 01:31:24
|
I see... in that case, I guess it would be a suitable thing to do... =20 regards, Mathew ----- Original Message -----=20 From: Bob Diss=20 To: Mathew Robertson=20 Sent: Thursday, October 07, 2004 11:18 AM Subject: Re: [htmltmpl] Allow coderef's for LOOP variables I guess maybe because I lean more towards letting the template drive = the code, and not the other way around. The code thinks of itself as a = resource provider, and queries the template for resources it needs. It = doesn't know anything about how those resources are going to be used. = It's really up to the template, through it's logic, to make appropriate = use of that stuff. I know that sounds kind-of ambiguous, so maybe a more concrete example = is appropriate. Let's assume that the task at hand is to fill out some = sort of response form. In addition to processing the form input, the = code can also generate a list of know email addresses, a history of the = user's form items, a list of cities and states, etc. -- all of which we = (assume) are expensive things to do. Now, it's up to the template to = make good use of these resources as it renders a suitable UI. It may = start by offering a simple fill-in the form form screen, with options to = pop-up the email address list, prior form request, the city-state list. = Or it might walk the user through the form items wizard-like, asking for = one bit of information at a time -- you get the idea. It's up to the = template to decide which of these resources it's going to use. The code = really has no idea what things trigger the need for what resources. If = it did, I'd wind up tightly coupling my UI to my code -- which is the = big thing I'm trying to avoid. So, all the code can do is query the template for the names of the = variables that are referenced, and make them. The problem comes in when = the item is an expensive TMPL_LOOP variable. I'd much rather make that = only when I'm absolutely sure it's going to be used. The query = interface can't tell me that -- it just tells me what's in there. Hence = the need to postpone the actual generation until rendering time. I hope you follow along with my (admittedly contrived) example. In my = real-life case, I wind up using the same code base for different = websites, each of which implement a given task in a completly different = manner. The only way I can do that is by keeping the UI decisions out = of the code. - Bob Mathew Robertson <mat...@re...> wrote: hmm... not sure about that... If your TMPL_IF takes one branch which doesn't result in generating = output, why didn't the Perl code test the same value and not generate = the unused H::T param data? Mathew ----- Original Message -----=20 From: Bob Diss=20 To: htm...@li...=20 Sent: Wednesday, October 06, 2004 11:01 PM Subject: [htmltmpl] Allow coderef's for LOOP variables My templates tend to be pretty complicated, and often have = different If/Then/Else paths that they could follow when rendering. I = also have loop objects which are expensive to build (time-wise). = Therefore, I query() the template only build them if the template = references them. However, this didn't give me the best performance = savings, because often the template would still not use the expensive = loop object, because it didn't follow that If/Then/Else path. To "fix" this I arranged for my expensive loop object to be built = as a call-back, and stored a coderef as the param value. However, I = found that HTML::Template didn't allow code references for loop = variables. I implemented the work-arounds for this by allowing a loop = variable to be a coderef, and then detecting it later and de-referencing = it at output time. What are the thoughts on doing this? It does weaken (or at least = postpone) the strong type checking that occurs for a loop value (must be = an arrayref). -Bob Diss -------------------------------------------------------------------------= - Do you Yahoo!? vote.yahoo.com - Register online to vote today! -------------------------------------------------------------------------= ----- Do you Yahoo!? Yahoo! Mail - You care about security. So do we. |
From: Mathew R. <mat...@re...> - 2004-10-07 00:05:54
|
what a good idea... could you make the code available? Mathew ----- Original Message -----=20 From: Bob Diss=20 To: htm...@li...=20 Sent: Thursday, October 07, 2004 7:06 AM Subject: [htmltmpl] HTML::Template::Compile - anonymous sub and eval = H::T An item I ran into lately is a desire to squeeze even more performance = out of H::T. Since I'm in a mod_perl environment, I typically load up a = handfull of templates and then render them over and over again. To help = this out, I built a version of H::T that cross-compiles the stack-based = code into an anonymous sub(), and then eval's it to render the output. = I've found this to offer a significant performance benefit over stock = H::T. One thing to know about my environment is that I'm on a Win32 platform = (currently). Therefore, H::T::JIT wasn't an option for me. Anyway, here's some performance numbers. This is a simple program = that creates a template, loads a bunch of parameters, and then renders = it 100 times. I've included the dprofpp results for H::T and = H::T::Compile. HTML::Template -------------- C:\Test>perl -d:DProf foo.pl C:\Test>dprofpp Total Elapsed Time =3D 152.7336 Seconds User+System Time =3D 151.4206 Seconds Exclusive Times %Time ExclSec CumulS #Calls sec/call Csec/c Name 86.7 131.4 155.75 11400 0.0115 0.0137 HTML::Template::output 11.8 17.92 17.921 539401 0.0000 0.0000 HTML::Template::param 1.56 2.369 2.369 52900 0.0000 0.0000 = HTML::Template::_globalize_vars 1.33 2.020 2.020 52900 0.0000 0.0000 = HTML::Template::_unglobalize_vars 0.66 1.000 1.000 11300 0.0001 0.0001 = HTML::Template::clear_params 0.48 0.722 151.05 1200 0.0006 0.1259 = HTML::Template::LOOP::output 0.24 0.357 0.392 1 0.3567 0.3925 HTML::Template::_parse 0.11 0.169 0.169 4900 0.0000 0.0000 = HTML::Template::URLESCAPE::escape 0.10 0.144 0.144 5800 0.0000 0.0000 = HTML::Template::ESCAPE::escape 0.05 0.070 0.139 1 0.0699 0.1392 main::BEGIN 0.03 0.050 0.069 9 0.0055 0.0077 HTML::Template::BEGIN 0.01 0.020 0.020 1 0.0200 0.0200 = HTML::Template::_init_template 0.01 0.017 0.017 577 0.0000 0.0000 HTML::Template::VAR::new 0.01 0.010 0.010 2 0.0050 0.0050 DynaLoader::BEGIN 0.01 0.010 0.010 3 0.0033 0.0033 vars::BEGIN C:\Test>dprofpp -r Total Elapsed Time =3D 152.7046 Seconds Real Time =3D 152.7046 Seconds Exclusive Times %Time ExclSec CumulS #Calls sec/call Csec/c Name 86.8 132.5 157.04 11400 0.0116 0.0138 HTML::Template::output 11.7 17.94 17.945 539401 0.0000 0.0000 HTML::Template::param 1.58 2.410 2.410 52900 0.0000 0.0000 = HTML::Template::_globalize_vars 1.33 2.025 2.025 52900 0.0000 0.0000 = HTML::Template::_unglobalize_vars 0.66 1.009 1.009 11300 0.0001 0.0001 = HTML::Template::clear_params 0.49 0.742 152.31 1200 0.0006 0.1269 = HTML::Template::LOOP::output 0.24 0.367 0.402 1 0.3667 0.4025 HTML::Template::_parse 0.11 0.168 0.168 4900 0.0000 0.0000 = HTML::Template::URLESCAPE::escape 0.10 0.154 0.154 5800 0.0000 0.0000 = HTML::Template::ESCAPE::escape 0.05 0.070 0.149 1 0.0699 0.1492 main::BEGIN 0.03 0.050 0.079 9 0.0055 0.0088 HTML::Template::BEGIN 0.01 0.020 0.020 1 0.0200 0.0200 = HTML::Template::_init_template 0.01 0.020 0.020 3 0.0067 0.0066 vars::BEGIN 0.01 0.017 0.017 577 0.0000 0.0000 HTML::Template::VAR::new 0.01 0.010 0.010 2 0.0050 0.0050 DynaLoader::BEGIN HTML::Template::Compile ----------------------- C:\Test>perl -d:DProf bar.pl C:\Test>dprofpp Exporter::export has -6 unstacked calls in outer Exporter::Heavy::heavy_export has 6 unstacked calls in outer Total Elapsed Time =3D 36.19448 Seconds User+System Time =3D 35.85548 Seconds Exclusive Times %Time ExclSec CumulS #Calls sec/call Csec/c Name 43.6 15.65 27.876 11400 0.0014 0.0024 = HTML::Template::Compile::_runtime_ start 36.5 13.12 13.121 403804 0.0000 0.0000 HTML::Template::param 7.93 2.845 38.938 100 0.0285 0.3894 = HTML::Template::Compile::__ANON__ 6.69 2.397 2.397 52900 0.0000 0.0000 = HTML::Template::_globalize_vars 6.00 2.150 2.150 52900 0.0000 0.0000 = HTML::Template::_unglobalize_vars 4.15 1.489 1.621 87300 0.0000 0.0000 = HTML::Template::Compile::_runtime_ deref 2.97 1.065 1.065 11300 0.0001 0.0001 = HTML::Template::clear_params 1.84 0.661 0.752 1 0.6610 0.7515 = HTML::Template::Compile::_compile 1.05 0.377 0.392 1 0.3767 0.3925 HTML::Template::_parse 0.25 0.088 2.239 11400 0.0000 0.0002 = HTML::Template::Compile::_runtime_ stop 0.24 0.085 0.091 43 0.0020 0.0021 = HTML::Template::Compile::_generate 0.23 0.084 0.084 5800 0.0000 0.0000 = HTML::Template::Compile::_runtime_ escape 0.22 0.079 0.078 101 0.0008 0.0008 = HTML::Template::_find_file 0.17 0.060 0.248 8 0.0075 0.0310 = HTML::Template::Compile::BEGIN 0.14 0.050 0.079 9 0.0055 0.0088 HTML::Template::BEGIN C:\Test>dprofpp -r Exporter::export has -6 unstacked calls in outer Exporter::Heavy::heavy_export has 6 unstacked calls in outer Total Elapsed Time =3D 36.14248 Seconds Real Time =3D 36.14248 Seconds Exclusive Times %Time ExclSec CumulS #Calls sec/call Csec/c Name 44.1 15.93 28.116 11400 0.0014 0.0025 = HTML::Template::Compile::_runtime_ start 36.1 13.05 13.053 403804 0.0000 0.0000 HTML::Template::param 8.17 2.954 39.267 100 0.0295 0.3927 = HTML::Template::Compile::__ANON__ 6.69 2.419 2.419 52900 0.0000 0.0000 = HTML::Template::_globalize_vars 5.97 2.158 2.158 52900 0.0000 0.0000 = HTML::Template::_unglobalize_vars 4.02 1.453 1.605 87300 0.0000 0.0000 = HTML::Template::Compile::_runtime_ deref 2.91 1.051 1.051 11300 0.0001 0.0001 = HTML::Template::clear_params 1.83 0.661 0.752 1 0.6610 0.7515 = HTML::Template::Compile::_compile 1.04 0.377 0.392 1 0.3767 0.3925 HTML::Template::_parse 0.26 0.094 0.094 5800 0.0000 0.0000 = HTML::Template::Compile::_runtime_ escape 0.24 0.088 2.247 11400 0.0000 0.0002 = HTML::Template::Compile::_runtime_ stop 0.24 0.085 0.091 43 0.0020 0.0021 = HTML::Template::Compile::_generate 0.19 0.069 0.078 101 0.0007 0.0008 = HTML::Template::_find_file 0.17 0.060 0.258 8 0.0075 0.0322 = HTML::Template::Compile::BEGIN 0.16 0.058 0.058 4900 0.0000 0.0000 = HTML::Template::Compile::_runtime_ urlescape I've been using this on my site for about a month now. It supports = all of the features of H::T, and also includes the enhancements I've = done locally. I would like to figure out a way to share it (if it's of = interest) 'cause I'm sure the manner in which it's implemented could = always be improved. - Bob Diss -------------------------------------------------------------------------= ----- Do you Yahoo!? vote.yahoo.com - Register online to vote today! |
From: Mathew R. <mat...@re...> - 2004-10-07 00:04:53
|
hmm... not sure about that... If your TMPL_IF takes one branch which doesn't result in generating = output, why didn't the Perl code test the same value and not generate = the unused H::T param data? Mathew ----- Original Message -----=20 From: Bob Diss=20 To: htm...@li...=20 Sent: Wednesday, October 06, 2004 11:01 PM Subject: [htmltmpl] Allow coderef's for LOOP variables My templates tend to be pretty complicated, and often have different = If/Then/Else paths that they could follow when rendering. I also have = loop objects which are expensive to build (time-wise). Therefore, I = query() the template only build them if the template references them. = However, this didn't give me the best performance savings, because often = the template would still not use the expensive loop object, because it = didn't follow that If/Then/Else path. To "fix" this I arranged for my expensive loop object to be built as a = call-back, and stored a coderef as the param value. However, I found = that HTML::Template didn't allow code references for loop variables. I implemented the work-arounds for this by allowing a loop variable to = be a coderef, and then detecting it later and de-referencing it at = output time. What are the thoughts on doing this? It does weaken (or at least = postpone) the strong type checking that occurs for a loop value (must be = an arrayref). -Bob Diss -------------------------------------------------------------------------= ----- Do you Yahoo!? vote.yahoo.com - Register online to vote today! |
From: Mathew R. <mat...@re...> - 2004-10-07 00:03:07
|
I'd generally agree (mostly) -> the formatting of data is up to the GUI = designer, eg if I want the number 1000000 to contain comma's, I = shouldn't need to get the Perl programmer to generate the a stringified = value caontaining them. Although, there would need to be alimit on this functionality, as you = might end up making a scripting language just to implement this extra = functionality, in a way which is extensible. In which case, you might = as well just write a Perl module to do the formatting for you. regards, Mathew ----- Original Message -----=20 From: Bob Diss=20 To: htm...@li...=20 Sent: Wednesday, October 06, 2004 10:47 PM Subject: [htmltmpl] FORMAT=3D enhancement to <TMPL_VAR> construct Greetings! In using HTML::Template I found somewhat limited by the = lack of formatting ability in the template language itself. While I = recognize the need for a separation between coding and layout, I often = found myself making duplicate copies of a value in different formats so = that the layout people would have the version they need. For example: = sometimes they would want the value in all uppercase (for a section = heading), and then again they want it in all lowercase, or sometimes = they want just the first few words (to layout an article teaser). To do this I implemented an idea I had seen done by a PHP translation = of HTML::Template found at = http://vlib.activefish.com/docs/vlibTemplate.html. The = "FORMAT=3Dsome-value" attribute to the <TMPL_VAR> construct allows the = designer to alter the format of the variable. I implemented several = built-in formatters, including: FORMAT=3Dlc -- lowercase the value FORMAT=3Duc -- uppercase the value FORMAT=3Ducfirst -- ucfirst each word in the value FORMAT=3Dlcucfirst -- first lowercase the value, then ucfirst each = word FORMAT=3Dreverse -- reverse the value FORMAT=3Dlength -- output the length of the value FORMAT=3D#c -- output the first # characters of the value FORMAT=3D#w -- output the first # words of the value FORMAT=3D#l -- output the first # lines of the value FORMAT=3Dxxxxx -- call the custom formatter 'xxxxx' which was = declared in the 'formatters' hash when the template object was new'ed Note that FORMAT does not replace ESCAPE. Instead, they happen in = sequence. First, the value is formatted, then it is escaped. Comments? Thoughts? Suggestions? - Bob Diss __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around=20 http://mail.yahoo.com=20 |
From: Mathew R. <mat...@re...> - 2004-10-06 23:58:51
|
My local copy of H::T is modified so that a) you can create custom = TMPL_xxx tags, and b) you can create custom ESCAPE tags by overloading a = H::T::Escape (I have factured out that functionality into seperate = modules). I'd be interested to how you did this MARK stuff - I have previously = used H::T::Expr to generate custom layouts, although I consider this = solution to be rather hack'ish since I tend to think that TMPL_LOOP's = need not always loop from start to finish of Perl array. regards, Mathew ----- Original Message -----=20 From: Bob Diss=20 To: htm...@li...=20 Sent: Wednesday, October 06, 2004 10:31 PM Subject: [htmltmpl] MARK=3D enhancement to the HTML::Template LOOP = construct Greetings everyone! I've been using HTML::Template on my site for = several years now, and I'm really pleased with what it can do and how = easy it is to teach my HTML'ers. I'd like to share with you some = enhancements I've done to make it even more powerful (for me, at least). I make heavy use of the <TMPL_LOOP> tag on my site. However, I seem = to always want to do something that's hard. For example, I want to = layout the loop items in three columns (instead of two using the __ODD__ = tag). Or, I want to layout just the first 5 items and (if there are = more) make a link to "see more". Or, I want to lay items in 4 balanced = columns (i.e. A-G arranged vertically in the first column, H-N in the = second, O-U in the third, V-Z in the last). To accomplish this, I implemented a "MARK=3Dsome-value" tag for the = <TMPL_LOOP> construct. This MARK tag requests that the additional loop = context variables __MARK__, __MARKFIRST__, and __MARKLAST__ be set. = There are four possible formats for the MARK value. If I say "MARK=3D3" then the first item and every third item = thereafter will have __MARK__ set to true (i.e. it will be true for = items 1, 4, 7, 10, etc.). __MARKFIRST__ is set true whenever __MARK__ = is true, and __MARKLAST__ is set true for the last item before __MARK__ = is true (i.e. items 3, 6, 9, etc.). With this I can easily setup = N-column displays in HTML by triggering my <TR> starts and ends with = __MARKFIRST__ and __MARKLAST__. If I say "MARK=3D-6" then all the items before item 6 (items 1 through = 5) will be __MARK__'ed true. The first item will be __MARKFIRST__, and = the 5th item (or the last item if there are less than 6 items) will be = __MARKLAST__. This helps me process a list of items when I just want to = show the first N, but want to be smart enough to know if there are more = items to talk about. Since the <TMPL_LOOP> iterates over all the items, = I can trap the __LAST__ item and check to see if it was __MARK__'ed. If = so, I can offer a "more" link. Of course, there's a complimentary "MARK=3D+5" option to mark the = items that occur after item 5 (items 6 on). Finally, the hardest thing to do is layout balanced columns. To do = this I specify "MARK=3DTOTGRP/GRP", as in "MARK=3D3/2". This tells the = loop to divide the items in to TOTGRP balanced groupings (three in this = case), and __MARK__ the items in the GRP grouping (two in this case). = For example: I often have a list of alphabetized names, and I want to = show them in a way that people are used to, which is to have them = vertically alphabetized, and split into N balanced columns. Using this = tag my HTML becomes something like this: <TABLE><TR VALIGN=3D"TOP"> <TD> <TMPL_LOOP NAME=3D"foo" MARK=3D"3/1"> <TMPL_IF __MARK__> output an item in column 1<BR></TMPL_IF> </TMPL_LOOP> </TD>=20 <TD> <TMPL_LOOP NAME=3D"foo" MARK=3D"3/2"> <TMPL_IF __MARK__> output an item in column 2 <BR></TMPL_IF> </TMPL_LOOP> </TD>=20 <TD> <TMPL_LOOP NAME=3D"foo" MARK=3D"3/3"> <TMPL_IF __MARK__> output an item in column 3 <BR></TMPL_IF> </TMPL_LOOP> </TD> </TR></TABLE> I've found these enhancements to be very useful, as they save me from = coding layout decision flags in my loop items, while enabling more = sophisticated layout possibilities. Comments? Thoughts? Suggestions? It works for me -- would it work = for anyone else? -Bob Diss -------------------------------------------------------------------------= ----- Do you Yahoo!? vote.yahoo.com - Register online to vote today! |
From: Bob D. <rl...@ya...> - 2004-10-06 21:06:27
|
An item I ran into lately is a desire to squeeze even more performance out of H::T. Since I'm in a mod_perl environment, I typically load up a handfull of templates and then render them over and over again. To help this out, I built a version of H::T that cross-compiles the stack-based code into an anonymous sub(), and then eval's it to render the output. I've found this to offer a significant performance benefit over stock H::T. One thing to know about my environment is that I'm on a Win32 platform (currently). Therefore, H::T::JIT wasn't an option for me. Anyway, here's some performance numbers. This is a simple program that creates a template, loads a bunch of parameters, and then renders it 100 times. I've included the dprofpp results for H::T and H::T::Compile. HTML::Template -------------- C:\Test>perl -d:DProf foo.pl C:\Test>dprofpp Total Elapsed Time = 152.7336 Seconds User+System Time = 151.4206 Seconds Exclusive Times %Time ExclSec CumulS #Calls sec/call Csec/c Name 86.7 131.4 155.75 11400 0.0115 0.0137 HTML::Template::output 11.8 17.92 17.921 539401 0.0000 0.0000 HTML::Template::param 1.56 2.369 2.369 52900 0.0000 0.0000 HTML::Template::_globalize_vars 1.33 2.020 2.020 52900 0.0000 0.0000 HTML::Template::_unglobalize_vars 0.66 1.000 1.000 11300 0.0001 0.0001 HTML::Template::clear_params 0.48 0.722 151.05 1200 0.0006 0.1259 HTML::Template::LOOP::output 0.24 0.357 0.392 1 0.3567 0.3925 HTML::Template::_parse 0.11 0.169 0.169 4900 0.0000 0.0000 HTML::Template::URLESCAPE::escape 0.10 0.144 0.144 5800 0.0000 0.0000 HTML::Template::ESCAPE::escape 0.05 0.070 0.139 1 0.0699 0.1392 main::BEGIN 0.03 0.050 0.069 9 0.0055 0.0077 HTML::Template::BEGIN 0.01 0.020 0.020 1 0.0200 0.0200 HTML::Template::_init_template 0.01 0.017 0.017 577 0.0000 0.0000 HTML::Template::VAR::new 0.01 0.010 0.010 2 0.0050 0.0050 DynaLoader::BEGIN 0.01 0.010 0.010 3 0.0033 0.0033 vars::BEGIN C:\Test>dprofpp -r Total Elapsed Time = 152.7046 Seconds Real Time = 152.7046 Seconds Exclusive Times %Time ExclSec CumulS #Calls sec/call Csec/c Name 86.8 132.5 157.04 11400 0.0116 0.0138 HTML::Template::output 11.7 17.94 17.945 539401 0.0000 0.0000 HTML::Template::param 1.58 2.410 2.410 52900 0.0000 0.0000 HTML::Template::_globalize_vars 1.33 2.025 2.025 52900 0.0000 0.0000 HTML::Template::_unglobalize_vars 0.66 1.009 1.009 11300 0.0001 0.0001 HTML::Template::clear_params 0.49 0.742 152.31 1200 0.0006 0.1269 HTML::Template::LOOP::output 0.24 0.367 0.402 1 0.3667 0.4025 HTML::Template::_parse 0.11 0.168 0.168 4900 0.0000 0.0000 HTML::Template::URLESCAPE::escape 0.10 0.154 0.154 5800 0.0000 0.0000 HTML::Template::ESCAPE::escape 0.05 0.070 0.149 1 0.0699 0.1492 main::BEGIN 0.03 0.050 0.079 9 0.0055 0.0088 HTML::Template::BEGIN 0.01 0.020 0.020 1 0.0200 0.0200 HTML::Template::_init_template 0.01 0.020 0.020 3 0.0067 0.0066 vars::BEGIN 0.01 0.017 0.017 577 0.0000 0.0000 HTML::Template::VAR::new 0.01 0.010 0.010 2 0.0050 0.0050 DynaLoader::BEGIN HTML::Template::Compile ----------------------- C:\Test>perl -d:DProf bar.pl C:\Test>dprofpp Exporter::export has -6 unstacked calls in outer Exporter::Heavy::heavy_export has 6 unstacked calls in outer Total Elapsed Time = 36.19448 Seconds User+System Time = 35.85548 Seconds Exclusive Times %Time ExclSec CumulS #Calls sec/call Csec/c Name 43.6 15.65 27.876 11400 0.0014 0.0024 HTML::Template::Compile::_runtime_ start 36.5 13.12 13.121 403804 0.0000 0.0000 HTML::Template::param 7.93 2.845 38.938 100 0.0285 0.3894 HTML::Template::Compile::__ANON__ 6.69 2.397 2.397 52900 0.0000 0.0000 HTML::Template::_globalize_vars 6.00 2.150 2.150 52900 0.0000 0.0000 HTML::Template::_unglobalize_vars 4.15 1.489 1.621 87300 0.0000 0.0000 HTML::Template::Compile::_runtime_ deref 2.97 1.065 1.065 11300 0.0001 0.0001 HTML::Template::clear_params 1.84 0.661 0.752 1 0.6610 0.7515 HTML::Template::Compile::_compile 1.05 0.377 0.392 1 0.3767 0.3925 HTML::Template::_parse 0.25 0.088 2.239 11400 0.0000 0.0002 HTML::Template::Compile::_runtime_ stop 0.24 0.085 0.091 43 0.0020 0.0021 HTML::Template::Compile::_generate 0.23 0.084 0.084 5800 0.0000 0.0000 HTML::Template::Compile::_runtime_ escape 0.22 0.079 0.078 101 0.0008 0.0008 HTML::Template::_find_file 0.17 0.060 0.248 8 0.0075 0.0310 HTML::Template::Compile::BEGIN 0.14 0.050 0.079 9 0.0055 0.0088 HTML::Template::BEGIN C:\Test>dprofpp -r Exporter::export has -6 unstacked calls in outer Exporter::Heavy::heavy_export has 6 unstacked calls in outer Total Elapsed Time = 36.14248 Seconds Real Time = 36.14248 Seconds Exclusive Times %Time ExclSec CumulS #Calls sec/call Csec/c Name 44.1 15.93 28.116 11400 0.0014 0.0025 HTML::Template::Compile::_runtime_ start 36.1 13.05 13.053 403804 0.0000 0.0000 HTML::Template::param 8.17 2.954 39.267 100 0.0295 0.3927 HTML::Template::Compile::__ANON__ 6.69 2.419 2.419 52900 0.0000 0.0000 HTML::Template::_globalize_vars 5.97 2.158 2.158 52900 0.0000 0.0000 HTML::Template::_unglobalize_vars 4.02 1.453 1.605 87300 0.0000 0.0000 HTML::Template::Compile::_runtime_ deref 2.91 1.051 1.051 11300 0.0001 0.0001 HTML::Template::clear_params 1.83 0.661 0.752 1 0.6610 0.7515 HTML::Template::Compile::_compile 1.04 0.377 0.392 1 0.3767 0.3925 HTML::Template::_parse 0.26 0.094 0.094 5800 0.0000 0.0000 HTML::Template::Compile::_runtime_ escape 0.24 0.088 2.247 11400 0.0000 0.0002 HTML::Template::Compile::_runtime_ stop 0.24 0.085 0.091 43 0.0020 0.0021 HTML::Template::Compile::_generate 0.19 0.069 0.078 101 0.0007 0.0008 HTML::Template::_find_file 0.17 0.060 0.258 8 0.0075 0.0322 HTML::Template::Compile::BEGIN 0.16 0.058 0.058 4900 0.0000 0.0000 HTML::Template::Compile::_runtime_ urlescape I've been using this on my site for about a month now. It supports all of the features of H::T, and also includes the enhancements I've done locally. I would like to figure out a way to share it (if it's of interest) 'cause I'm sure the manner in which it's implemented could always be improved. - Bob Diss --------------------------------- Do you Yahoo!? vote.yahoo.com - Register online to vote today! |
From: Philip T. <phi...@gm...> - 2004-10-06 13:10:26
|
Sometime Today, Bob Diss assembled some asciibets to say: > Greetings! In using HTML::Template I found somewhat limited by the > lack of formatting ability in the template language itself. While I > recognize the need for a separation between coding and layout, I often > found myself making duplicate copies of a value in different formats > so that the layout people would have the version they need. For > example: sometimes they would want the value in all uppercase (for a > section heading), and then again they want it in all lowercase, or I think you want the text-transform CSS rule. -- Eureka! -- Archimedes |
From: Bob D. <rl...@ya...> - 2004-10-06 13:01:26
|
My templates tend to be pretty complicated, and often have different If/Then/Else paths that they could follow when rendering. I also have loop objects which are expensive to build (time-wise). Therefore, I query() the template only build them if the template references them. However, this didn't give me the best performance savings, because often the template would still not use the expensive loop object, because it didn't follow that If/Then/Else path. To "fix" this I arranged for my expensive loop object to be built as a call-back, and stored a coderef as the param value. However, I found that HTML::Template didn't allow code references for loop variables. I implemented the work-arounds for this by allowing a loop variable to be a coderef, and then detecting it later and de-referencing it at output time. What are the thoughts on doing this? It does weaken (or at least postpone) the strong type checking that occurs for a loop value (must be an arrayref). -Bob Diss --------------------------------- Do you Yahoo!? vote.yahoo.com - Register online to vote today! |
From: Bob D. <rl...@ya...> - 2004-10-06 12:47:33
|
Greetings! In using HTML::Template I found somewhat limited by the lack of formatting ability in the template language itself. While I recognize the need for a separation between coding and layout, I often found myself making duplicate copies of a value in different formats so that the layout people would have the version they need. For example: sometimes they would want the value in all uppercase (for a section heading), and then again they want it in all lowercase, or sometimes they want just the first few words (to layout an article teaser). To do this I implemented an idea I had seen done by a PHP translation of HTML::Template found at http://vlib.activefish.com/docs/vlibTemplate.html. The "FORMAT=some-value" attribute to the <TMPL_VAR> construct allows the designer to alter the format of the variable. I implemented several built-in formatters, including: FORMAT=lc -- lowercase the value FORMAT=uc -- uppercase the value FORMAT=ucfirst -- ucfirst each word in the value FORMAT=lcucfirst -- first lowercase the value, then ucfirst each word FORMAT=reverse -- reverse the value FORMAT=length -- output the length of the value FORMAT=#c -- output the first # characters of the value FORMAT=#w -- output the first # words of the value FORMAT=#l -- output the first # lines of the value FORMAT=xxxxx -- call the custom formatter 'xxxxx' which was declared in the 'formatters' hash when the template object was new'ed Note that FORMAT does not replace ESCAPE. Instead, they happen in sequence. First, the value is formatted, then it is escaped. Comments? Thoughts? Suggestions? - Bob Diss __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
From: Bob D. <rl...@ya...> - 2004-10-06 12:31:45
|
Greetings everyone! I've been using HTML::Template on my site for several years now, and I'm really pleased with what it can do and how easy it is to teach my HTML'ers. I'd like to share with you some enhancements I've done to make it even more powerful (for me, at least). I make heavy use of the <TMPL_LOOP> tag on my site. However, I seem to always want to do something that's hard. For example, I want to layout the loop items in three columns (instead of two using the __ODD__ tag). Or, I want to layout just the first 5 items and (if there are more) make a link to "see more". Or, I want to lay items in 4 balanced columns (i.e. A-G arranged vertically in the first column, H-N in the second, O-U in the third, V-Z in the last). To accomplish this, I implemented a "MARK=some-value" tag for the <TMPL_LOOP> construct. This MARK tag requests that the additional loop context variables __MARK__, __MARKFIRST__, and __MARKLAST__ be set. There are four possible formats for the MARK value. If I say "MARK=3" then the first item and every third item thereafter will have __MARK__ set to true (i.e. it will be true for items 1, 4, 7, 10, etc.). __MARKFIRST__ is set true whenever __MARK__ is true, and __MARKLAST__ is set true for the last item before __MARK__ is true (i.e. items 3, 6, 9, etc.). With this I can easily setup N-column displays in HTML by triggering my <TR> starts and ends with __MARKFIRST__ and __MARKLAST__. If I say "MARK=-6" then all the items before item 6 (items 1 through 5) will be __MARK__'ed true. The first item will be __MARKFIRST__, and the 5th item (or the last item if there are less than 6 items) will be __MARKLAST__. This helps me process a list of items when I just want to show the first N, but want to be smart enough to know if there are more items to talk about. Since the <TMPL_LOOP> iterates over all the items, I can trap the __LAST__ item and check to see if it was __MARK__'ed. If so, I can offer a "more" link. Of course, there's a complimentary "MARK=+5" option to mark the items that occur after item 5 (items 6 on). Finally, the hardest thing to do is layout balanced columns. To do this I specify "MARK=TOTGRP/GRP", as in "MARK=3/2". This tells the loop to divide the items in to TOTGRP balanced groupings (three in this case), and __MARK__ the items in the GRP grouping (two in this case). For example: I often have a list of alphabetized names, and I want to show them in a way that people are used to, which is to have them vertically alphabetized, and split into N balanced columns. Using this tag my HTML becomes something like this: <TABLE><TR VALIGN="TOP"> <TD> <TMPL_LOOP NAME="foo" MARK="3/1"> <TMPL_IF __MARK__> output an item in column 1<BR></TMPL_IF> </TMPL_LOOP> </TD> <TD> <TMPL_LOOP NAME="foo" MARK="3/2"> <TMPL_IF __MARK__> output an item in column 2 <BR></TMPL_IF> </TMPL_LOOP> </TD> <TD> <TMPL_LOOP NAME="foo" MARK="3/3"> <TMPL_IF __MARK__> output an item in column 3 <BR></TMPL_IF> </TMPL_LOOP> </TD> </TR></TABLE> I've found these enhancements to be very useful, as they save me from coding layout decision flags in my loop items, while enabling more sophisticated layout possibilities. Comments? Thoughts? Suggestions? It works for me -- would it work for anyone else? -Bob Diss --------------------------------- Do you Yahoo!? vote.yahoo.com - Register online to vote today! |
From: Carl F. <C.A...@du...> - 2004-10-04 15:11:06
|
Hi Ken, I've tried this, and it works. How does it compare with what you're doing? File test.pl ------------ #!/usr/bin/perl use warnings; use strict; use lib '.'; use Bar; Bar::foo(); File Bar.pm ----------- package Bar; use strict; use HTML::Template; sub foo { my $tmpl = HTML::Template->new (filehandle => *DATA); $tmpl->param(bar => 'works'); print $tmpl->output; } 1; __DATA__ foo <TMPL_VAR bar> baz ----- Carl >>> ken <ke...@sp...> 04/10/2004 11:43:16 >>> Carl Franks wrote: > > >>> <gr...@sp...> 02/10/2004 23:41:36 >>> > > > >Anyone ideas on what is going on? Any suggestions welcome. > > > >Thanks in advance, > >-Ken > > Hi Ken, > > Try this instead (below), noticed that I pass the DATA fileglob (*DATA) > directly to HTML::Template->new > > Carl > > #!/usr/bin/perl > use strict; > use warnings; > Foo->run(); > package Foo; > use HTML::Template; > sub run{ > my $template = HTML::Template->new(filehandle => *DATA, > die_on_bad_params=>1, strict=>1); > $template->param(VALUE=>'xx'); > print $template->output; > } > > 1; > __DATA__ > <html> > <head> > </head> > <body> > <TMPL_VAR NAME=VALUE> > </body> > </html> > [ken@darkstar DBWebForm]$ ./Foo.pm > <html> > <head> > </head> > <body> > xx > </body> > </html> > This gives me the same result. I have tried using the __DATA__ as a filehandle directly, copying to a arrayref, and copying to a scallarref, but all yield the same results. I do notice that running the file directly (e.g. ./Foo.pm) works, while using the module (e.g. perl -MFoo) gives a syntax error. The odd thing is, I can find no difference in the contents of the template file between invocations. I am completely stumped. Thanks for the suggestion, though. -Ken |
From: Offer K. <off...@gm...> - 2004-10-04 12:53:00
|
Hi, The site of the Israeli Perl Mongers, http://www.perl.org.il/ , now has a new, standards compliant look, courtesy of Perl and HTML::Template. The site sources are managed under Subversion, so anyone can freely download them if he/she wants to. Instructions are at the bottom of the About page. I'd like to thank Sam Tregar for creating HTML::Template, without which this site would have been much more difficult to build, and Gabor Szabo, head honcho for Israel.pm, for introducing me to HTML::Template. If you look at the code and see any mistakes, or you just think is is really ugly, please send patches... :-) Regards, -- Offer Kaye |
From: Carl F. <C.A...@du...> - 2004-10-04 08:25:32
|
>>> <gr...@sp...> 02/10/2004 23:41:36 >>> > >Anyone ideas on what is going on? Any suggestions welcome. > >Thanks in advance, >-Ken Hi Ken, Try this instead (below), noticed that I pass the DATA fileglob (*DATA) directly to HTML::Template->new Carl #!/usr/bin/perl use strict; use warnings; Foo->run(); package Foo; use HTML::Template; sub run{ my $template = HTML::Template->new(filehandle => *DATA, die_on_bad_params=>1, strict=>1); $template->param(VALUE=>'xx'); print $template->output; } 1; __DATA__ <html> <head> </head> <body> <TMPL_VAR NAME=VALUE> </body> </html> [ken@darkstar DBWebForm]$ ./Foo.pm <html> <head> </head> <body> xx </body> </html> |
From: Brad B. <bm...@Ma...> - 2004-10-03 12:06:32
|
On Sat, 2 Oct 2004 gr...@sp... wrote: > > > I have been having some trouble with a module I am working on that requires > HTML::Template. > > I am trying to use the __DATA__ section of the module as a default template to > fall back on if one is not supplied to my constructor. > > Here is a simple script that illustrates the issue: > > [ken@darkstar DBWebForm]$ cat Foo.pm > #!/usr/bin/perl > use strict; > use warnings; > Foo->run(); > package Foo; > use HTML::Template; > sub run{ > my @html = <DATA>; > my $template = HTML::Template->new(arrayref => \@html, > die_on_bad_params=>1, strict=>1); > $template->param(VALUE=>'xx'); > print $template->output; > } > > 1; > __DATA__ > <html> > <head> > </head> > <body> > <TMPL_VAR NAME=VALUE> > </body> > </html> > [ken@darkstar DBWebForm]$ ./Foo.pm > <html> > <head> > </head> > <body> > xx > </body> > </html> > [ken@darkstar DBWebForm]$ perl -MFoo > HTML::Template->new() : Syntax error in <TMPL_*> tag at > /fake/path/for/non/file/template : 5. at > /usr/lib/perl5/site_perl/5.8.0/HTML/Template.pm line 2288, <DATA> line 7. > Compilation failed in require, <DATA> line 7. > BEGIN failed--compilation aborted, <DATA> line 7. > > > Anyone ideas on what is going on? Any suggestions welcome. > > Thanks in advance, > -Ken FWIW, I don't get any errors when I run that (perl, v5.6.1). --Brad |
From: <gr...@sp...> - 2004-10-03 01:25:47
|
Quoting Gabor Szabo <ga...@pe...>: > On Sat, 2 Oct 2004 gr...@sp... wrote: >=20 > > > > > > I have been having some trouble with a module I am working on that > requires > > HTML::Template. > > > > I am trying to use the __DATA__ section of the module as a default te= mplate > to > > fall back on if one is not supplied to my constructor. >=20 > In one of my projects I am also using templates within the > code. I put the templates in a scalar variables. >=20 > You can take a look at the code at > http://search.cpan.org/dist/CGI-FileManager/ >=20 > Gabor Hey, thanks for the tip. I have already resorted to using a scalar, but i= t bugs me that I could not get my original attempt to work. I would still prefer= to use the __DATA__ section, or at least understand why I can't.=20 Thanks, -Ken ------------------------------------------------- This mail sent through IMP: http://horde.org/imp/ |
From: Gabor S. <ga...@pe...> - 2004-10-02 23:51:57
|
On Sat, 2 Oct 2004 gr...@sp... wrote: > > > I have been having some trouble with a module I am working on that requires > HTML::Template. > > I am trying to use the __DATA__ section of the module as a default template to > fall back on if one is not supplied to my constructor. In one of my projects I am also using templates within the code. I put the templates in a scalar variables. You can take a look at the code at http://search.cpan.org/dist/CGI-FileManager/ Gabor |
From: <gr...@sp...> - 2004-10-02 22:51:50
|
I have been having some trouble with a module I am working on that requir= es HTML::Template. I am trying to use the __DATA__ section of the module as a default templa= te to fall back on if one is not supplied to my constructor. Here is a simple script that illustrates the issue: [ken@darkstar DBWebForm]$ cat Foo.pm #!/usr/bin/perl use strict; use warnings; Foo->run(); package Foo; use HTML::Template; sub run{ my @html =3D <DATA>; my $template =3D HTML::Template->new(arrayref =3D> \@html, die_on_bad_params=3D>1, strict=3D>1); $template->param(VALUE=3D>'xx'); print $template->output; } =20 1; __DATA__ <html> <head> </head> <body> <TMPL_VAR NAME=3DVALUE> </body> </html> [ken@darkstar DBWebForm]$ ./Foo.pm <html> <head> </head> <body> xx </body> </html> [ken@darkstar DBWebForm]$ perl -MFoo HTML::Template->new() : Syntax error in <TMPL_*> tag at /fake/path/for/non/file/template : 5. at /usr/lib/perl5/site_perl/5.8.0/HTML/Template.pm line 2288, <DATA> line 7. Compilation failed in require, <DATA> line 7. BEGIN failed--compilation aborted, <DATA> line 7. Anyone ideas on what is going on? Any suggestions welcome. Thanks in advance, -Ken=20 ------------------------------------------------- This mail sent through IMP: http://horde.org/imp/ |
From: Charles K. C. <ccl...@ht...> - 2004-10-02 04:43:22
|
Thilo Planz <thi...@we...> wrote: : is there a way to set template parameters from within the : template? : : I would like to do this because I have pages that include : a common header (who doesn't?) [snip] : : so that the design people (who edit the templates, but not the : code) can set the page title (which is a purely presentational : issue most of the time) right in the template. I don't use H::T for page generation. I normally use it for content management. I did it for one site, however. It was an Apache server and we used SSI for page assembly and H::T for BBS output. The app templates didn't need to create site headers and footers, just some content to "drop-in" the page. HTH, Charles K. Clarkson -- Mobile Homes Specialist 254 968-8328 |
From: Mathew R. <mat...@re...> - 2004-10-01 04:56:06
|
Since filters are applied to each file as it is loaded, TMPL_SET's in = the parent file, are not in scope of the included file...thus it looks = like this isn't going to solve your problem. Mathew ----- Original Message -----=20 From: "Thilo Planz" <thi...@we...> To: "Mathew Robertson" <mat...@re...> Cc: <htm...@li...> Sent: Friday, October 01, 2004 2:44 PM Subject: Re: [htmltmpl] setting template parameters from within the = template? > > Attached is H::T::Filters module which implements some common = filters.=20 > > One of them is the TMPL_SET filter which can be used to do what you = > > are asking for. >=20 > Thanks, that is a useful module, but I cannot make it work on included = > files. > (The included file can not see what you TMPL_SET'ed is the "outer"=20 > template) >=20 >=20 > Thilo >=20 > |
From: Thilo P. <thi...@we...> - 2004-10-01 04:39:00
|
> Attached is H::T::Filters module which implements some common filters. > One of them is the TMPL_SET filter which can be used to do what you > are asking for. Thanks, that is a useful module, but I cannot make it work on included files. (The included file can not see what you TMPL_SET'ed is the "outer" template) Thilo |
From: Mathew R. <mat...@re...> - 2004-10-01 00:39:10
|
Attached is H::T::Filters module which implements some common filters. = One of them is the TMPL_SET filter which can be used to do what you are = asking for. Hope this helps, Mathew ----- Original Message -----=20 From: "Thilo Planz" <thi...@we...> To: <htm...@li...> Sent: Friday, October 01, 2004 10:32 AM Subject: [htmltmpl] setting template parameters from within the = template? > Hello, >=20 > is there a way to set template parameters from within the template? >=20 > I would like to do this because I have pages that include a common=20 > header (who doesn't ?) >=20 > <tmpl_include common_header> >=20 > and that header makes a page title. >=20 > <tmpl_var page_title> >=20 > At the moment, I have to set "page_title" in my application code = (well,=20 > not really, it is factored out into a data file, but still...). >=20 > $tmpl->param(page_title =3D> 'Whatever'); >=20 > It would be nice if I could do something like >=20 > <tmpl_param page_title Whatever> > <tmpl_include common_header> >=20 > or even >=20 > <tmpl_include common_header with-params: ' page_title =3D> Whatever' > >=20 > so that the design people (who edit the templates, but not the code)=20 > can set the page title (which is a purely presentational issue most of = > the time) > right in the template. >=20 >=20 > I am aware that this is probably difficult to implement, so just for=20 > the long-term wish-list... >=20 >=20 > Thilo >=20 >=20 >=20 > ------------------------------------------------------- > This SF.net email is sponsored by: IT Product Guide on = ITManagersJournal > Use IT products in your business? Tell us what you think of them. Give = us > Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out = more > http://productguide.itmanagersjournal.com/guidepromo.tmpl > _______________________________________________ > Html-template-users mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/html-template-users > |
From: Thilo P. <thi...@we...> - 2004-10-01 00:26:38
|
Hello, is there a way to set template parameters from within the template? I would like to do this because I have pages that include a common header (who doesn't ?) <tmpl_include common_header> and that header makes a page title. <tmpl_var page_title> At the moment, I have to set "page_title" in my application code (well, not really, it is factored out into a data file, but still...). $tmpl->param(page_title => 'Whatever'); It would be nice if I could do something like <tmpl_param page_title Whatever> <tmpl_include common_header> or even <tmpl_include common_header with-params: ' page_title => Whatever' > so that the design people (who edit the templates, but not the code) can set the page title (which is a purely presentational issue most of the time) right in the template. I am aware that this is probably difficult to implement, so just for the long-term wish-list... Thilo |
From: Mark S. <ma...@su...> - 2004-09-29 12:51:59
|
On 2004-09-28, Dale W. Hanzelka <dal...@in...> wrote: > What I am faced with is the SELECT constraints need to be dynamic and > the list could be up to 20 fields. When I output the rows, I need each > to split each column into a separate cell in a table. Why don't you try to solve this with HTML::Template, and post your code here if it doesn't work? Your case is not so simple that there simple answer to hand to you. Here's a hint to get started: > # set color to (odd)white || (even)lt grey > $color = (&odd_or_even($count) == 0) ? "#DDDDDD" : "#FFFFFF"; I'm curious what "odd_or_even()" might do. It sounds like the same thing as using the built-in "modulo" operator: ($count % 2 == 0) Besides, this can be solved in the template with the the __ODD__ functionality of HTML::Template. Mark -- http://mark.stosberg.com/ |