html-template-users Mailing List for HTML::Template (Page 34)
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: Rama S. <ra...@sa...> - 2005-03-17 03:15:51
|
Hello all, Thanks for the feed back. I had to specifically mention CHECKED="CHECKED" in the if statement to make it work. Simply by saying CHECKED alone (though a valid html attribute) does not seem to work. Basically to be more clear I tried doing this first <input type="radio" name="beepStatus" value="yes" <tmpl_if yesBeeps>cheecked</tmpl_if> it did not work. but by doing this it worked <input type="radio" name="beepStatus" value="yes" <tmpl_if yesBeeps>cheecked="checked"</tmpl_if> worked out well. I am guessing the html template engine must be looking for some name-value pairs and just by seeing a single value with out a matching name would have rejected interpreting it. Thanks to all and special thanks to simonartist. rama ----- Original Message ----- From: "Justin Simoni" <ju...@sk...> To: "Rama Srinivas" <ra...@sa...> Cc: <htm...@li...> Sent: Wednesday, March 16, 2005 2:28 PM Subject: Re: [htmltmpl] Problems with HTML::TEMPLATE I usually do something like this: <input type="radio" name="beepStatus" value="yes" <tmpl_if yesBeeps>checked="checked"</tmpl_if> /> Where, "yesBeeps" holds 1 or undefined. I guess your perl code would look something like: my $yesBeeps = 0; $yesBeeps = 1 if beepStatus eq "yes"; $tmpl_obj->param(yesBeeps => $yesBeeps); You may also want to look at HTML::FillinForm, which is a real time saver. If you have a large form with many form elements, HTML::Template gets a bit unwieldy: http://search.cpan.org/~tjmather/HTML-FillInForm-1.05/lib/HTML/ FillInForm.pm That way, you can pass HTML::FillnForm the value of, "beepStatus", and if there's a radiobutton that's associated with that value, it'll get checked. Like *magic*. I preprocess an HTML page with HTML::Template, and then give it to HTML::FillinForm to fill in the holes. Works really well. Saves me time. Makes me look like a supehero. Cheers, justinSimoni.Artist -- .: art http://justinsimoni.com .: phone 720 436 7701 On Mar 16, 2005, at 9:29 AM, Rama Srinivas wrote: > Hi > > I am reading information from a DB and prepopulating my form fields. > I am using HTML:TEMPLATES module to process my html tmpl files > > Some of the entries in my table are radio buttons. I am prepopulating > them but for some reason they donot seem to be prepopulated. I tried > to do a view page source to see if the html is properly generated. It > seems to do so. > All the other form fields are working fine. except radio buttons. > > IS there any known issue with radio buttons prepopulation when using > html tempalates. > > Here is the snippet of the code in my tmpl file. > > <td>Beeps: yes: > <input type="radio" name="beepStatus" value="yes" <TMPL_VAR > NAME="yesBeeps"> > > </td> > > The yesBeeps param displays checked or is empty string depending if > that radio button has to be prepopulated or not. But suprising even if > it is marked as checked it does not show that in my html page. > Any help or hints would help. Or i need to switch to the old style of > printing html doc through my perl program > thanks > rama |
From: Clifton R. <cli...@ti...> - 2005-03-17 02:32:01
|
On Wed, Mar 16, 2005 at 08:29:34AM -0800, Rama Srinivas wrote: > Some of the entries in my table are radio buttons. I am prepopulating > them but for some reason they donot seem to be prepopulated. I tried > to do a view page source to see if the html is properly generated. It > seems to do so. > > All the other form fields are working fine. except radio buttons. > > IS there any known issue with radio buttons prepopulation when using > html tempalates. No, I use HTML::Templates to preset radiobuttons to certain values, including multiline tables full of radio-buttons. > Here is the snippet of the code in my tmpl file. > > <td>Beeps: yes: > <input type="radio" name="beepStatus" value="yes" <TMPL_VAR > NAME="yesBeeps"> > > > </td> Looks OK to me, assuming yesBeeps is actually set to "checked". > The yesBeeps param displays checked or is empty string depending if > that radio button has to be prepopulated or not. But suprising even if > it is marked as checked it does not show that in my html page. For debugging purposes, it can be helpful to hide some comments in your template with TMPL_VAR values in them, e.g. <!-- Value of yesBeeps: <TMPL_VAR NAME="yesBeeps"> --> > Any help or hints would help. Or i need to switch to the old style of > printing html doc through my perl program That works too... -- Clifton -- Clifton Royston -- cli...@ti... Tiki Technologies Lead Programmer/Software Architect "I'm gonna tell my son to grow up pretty as the grass is green And whip-smart as the English Channel's wide..." -- 'Whip-Smart', Liz Phair |
From: Clifton R. <cli...@ti...> - 2005-03-17 02:28:32
|
On Wed, Mar 16, 2005 at 07:38:51PM +0300, Alex Kapranoff wrote: > * Rama Srinivas <ra...@sa...> [March 16 2005, 19:29]: > > Here is the snippet of the code in my tmpl file. > > > > <td>Beeps: yes: > > <input type="radio" name="beepStatus" value="yes" <TMPL_VAR > > NAME="yesBeeps"> > > > </td> > > Keep <TMPL_VAR> tag on one line. Not necessary in my H::T experience, FWIW. -- Clifton -- Clifton Royston -- cli...@ti... Tiki Technologies Lead Programmer/Software Architect "I'm gonna tell my son to grow up pretty as the grass is green And whip-smart as the English Channel's wide..." -- 'Whip-Smart', Liz Phair |
From: Justin S. <ju...@sk...> - 2005-03-16 22:28:39
|
I usually do something like this: <input type=3D"radio" name=3D"beepStatus" value=3D"yes"=A0 = <tmpl_if =20 yesBeeps>checked=3D"checked"</tmpl_if> /> Where, "yesBeeps" holds 1 or undefined. I guess your perl code would =20 look something like: my $yesBeeps =3D 0; $yesBeeps =3D 1 if beepStatus eq "yes"; $tmpl_obj->param(yesBeeps =3D> $yesBeeps); You may also want to look at HTML::FillinForm, which is a real time =20 saver. If you have a large form with many form elements, HTML::Template =20= gets a bit unwieldy: =09 http://search.cpan.org/~tjmather/HTML-FillInForm-1.05/lib/HTML/=20= FillInForm.pm That way, you can pass HTML::FillnForm the value of, "beepStatus", and =20= if there's a radiobutton that's associated with that value, it'll get =20= checked. Like *magic*. I preprocess an HTML page with HTML::Template, and then give it to =20 HTML::FillinForm to fill in the holes. Works really well. Saves me =20 time. Makes me look like a supehero. Cheers, justinSimoni.Artist -- .: art http://justinsimoni.com .: phone 720 436 7701 On Mar 16, 2005, at 9:29 AM, Rama Srinivas wrote: > Hi > =A0 > I am reading information from a DB and prepopulating my=A0form = fields.=A0 > I am using HTML:TEMPLATES module to process my html tmpl files > =A0 > Some of the entries in my table are radio buttons. I am prepopulating =20= > them but for some reason they donot seem to be prepopulated. I tried =20= > to do a view page source to see if the html is properly generated. It =20= > seems to do so. > All the other form fields are working fine. except radio buttons. > =A0 > IS there any known issue with radio buttons prepopulation when using =20= > html tempalates. > =A0 > Here is the snippet of the code in my tmpl file. > =A0 > <td>Beeps: yes: > <input type=3D"radio" name=3D"beepStatus" value=3D"yes"=A0 <TMPL_VAR =20= > NAME=3D"yesBeeps"> > > </td> > =A0 > The yesBeeps param displays checked or is empty string depending if =20= > that radio button has to be prepopulated or not. But suprising even if = =20 > it is marked as checked it does not show that in my html page. > Any help or hints would help. Or i need to switch to the old style of =20= > printing html doc through my perl program > thanks > rama |
From: Hugues de M. <hu...@ma...> - 2005-03-16 16:41:42
|
Hello, I see no reason why your code doesn't work. Did you try to display that = variable ? Personally, I use the following construct, which is a little heavier, = but possibily more in the spirit of completely separating HTML from = code: <td>Beeps: yes: <input type=3D"radio" name=3D"beepStatus" value=3D"yes" <TMPL_IF = NAME=3D"yesBeeps">CHECKED</TMPL_IF> > </td> Hope this helps, Hugues ----- Original Message -----=20 From: "Rama Srinivas" <ra...@sa...> To: <htm...@li...> Sent: Wednesday, March 16, 2005 5:29 PM Subject: [htmltmpl] Problems with HTML::TEMPLATE Hi I am reading information from a DB and prepopulating my form fields.=20 I am using HTML:TEMPLATES module to process my html tmpl files Some of the entries in my table are radio buttons. I am prepopulating = them but for some reason they donot seem to be prepopulated. I tried to = do a view page source to see if the html is properly generated. It seems = to do so. All the other form fields are working fine. except radio buttons. IS there any known issue with radio buttons prepopulation when using = html tempalates. Here is the snippet of the code in my tmpl file. <td>Beeps: yes: <input type=3D"radio" name=3D"beepStatus" value=3D"yes" <TMPL_VAR = NAME=3D"yesBeeps"> > </td> The yesBeeps param displays checked or is empty string depending if that = radio button has to be prepopulated or not. But suprising even if it is = marked as checked it does not show that in my html page. Any help or hints would help. Or i need to switch to the old style of = printing html doc through my perl program thanks rama |
From: Alex K. <ka...@ra...> - 2005-03-16 16:38:50
|
* Rama Srinivas <ra...@sa...> [March 16 2005, 19:29]: > Here is the snippet of the code in my tmpl file. > > <td>Beeps: yes: > <input type="radio" name="beepStatus" value="yes" <TMPL_VAR > NAME="yesBeeps"> > > </td> Keep <TMPL_VAR> tag on one line. -- Alex Kapranoff, $n=["1another7Perl213Just3hacker49"=~/\d|\D*/g]; $$n[0]={grep/\d/,@$n};print"@$n{1..4}\n" |
From: Rama S. <ra...@sa...> - 2005-03-16 16:30:02
|
Hi I am reading information from a DB and prepopulating my form fields.=20 I am using HTML:TEMPLATES module to process my html tmpl files Some of the entries in my table are radio buttons. I am prepopulating = them but for some reason they donot seem to be prepopulated. I tried to = do a view page source to see if the html is properly generated. It seems = to do so. All the other form fields are working fine. except radio buttons. IS there any known issue with radio buttons prepopulation when using = html tempalates. Here is the snippet of the code in my tmpl file. <td>Beeps: yes: <input type=3D"radio" name=3D"beepStatus" value=3D"yes" <TMPL_VAR = NAME=3D"yesBeeps"> > </td> The yesBeeps param displays checked or is empty string depending if that = radio button has to be prepopulated or not. But suprising even if it is = marked as checked it does not show that in my html page. Any help or hints would help. Or i need to switch to the old style of = printing html doc through my perl program thanks rama |
From: Mathew R. <mat...@re...> - 2005-03-06 23:49:09
|
There are some places in H::T where this is done... and I agree with = you -> its wrong if you need to subclass H::T... However, you should be able to simply change it to: $self->_new_from_loop(...) Perl will automatically dereference $self so as to determine the correct = package name - in fact ref($self) may return a string which is not = appropriate, in certain scenarios (eg: it may return HTML::Template when = it should return, say, MyHtmlTemplate). Then _new_from_loop should = implement: sub _new_from_loop { my $proto =3D shift; my $class =3D ref($proto) || $proto; ... } at this point $class will contain the correct package name. The same point could be said about H::T::E::output(), since it does = this: sub output { .... HTML::Template::output(...) ... } which again is incorrect if H::T::E is to be subclass'able. FWIW, the version of H::T that I have modified (available at: = http://members.optusnet.com.au/~mathew ) also makes this mistake in some = of the code that I have extended... ie we are all fallable... regards, Mathew ----- Original Message -----=20 From: "Cory Trese" <Ct...@on...> To: "Cory Trese" <Ct...@on...>; = <htm...@li...> Sent: Saturday, March 05, 2005 4:59 AM Subject: RE: [htmltmpl] Sub-Classing HTML::Template v2.7 > Hello, >=20 > I have found the root of my problem! All the code below was centered > around trying, and failing, to fully replace all instances of the > HTML::Template 'param( )' method within our code-base. I thought that > by building a sub-class and overriding param, I would be able to > accomplish this. However, I was unable to override all calls to = 'param( > )' -- some within HTML::Template remained using the SUPER::param( ). >=20 > I attempted to overwrite the package method, as seen below. This, > however, doesn't actually work. So again, no dice. Until I found the > following code in HTML::Template around Line #2112: >=20 > $loop->[HTML::Template::LOOP::TEMPLATE_HASH]{$starts_at} >=20 > =3D HTML::Template->_new_from_loop( >=20 > This does not seem friendly to sub-classes ... I didn't see any > references to this type of issue in Damian Conway's Object Oriented = Perl > book, but I found a solution that works great for my sub-classes. >=20 > $loop->[HTML::Template::LOOP::TEMPLATE_HASH]{$starts_at} >=20 > =3D ref( $self )->_new_from_loop( >=20 > This way, the "_new_from_loop" call always occurs against the correct > class -- HTML::Template or otherwise. I have no production code to = test > compatibility with HTML::Template::Expr so I cannot state if this type > of change will work for everyone trying to sub-class HTML::Template. >=20 > However, I do know that making this change caused my sub-classes to > completely work and I am very happy about that. >=20 > Sincerely, > Cory Trese > Lead Web Application Developer > =20 > O'NEIL & ASSOCIATES, INC. > 495 Byers Rd. > Miamisburg, Ohio 45342-3662 > Phone: (937) 865-0846 ext. 3038 > Fax: (937) 865-5858 > E-mail: [ct...@on...] >=20 >=20 > |> -----Original Message----- > |> From: htm...@li...=20 > |> [mailto:htm...@li...] On=20 > |> Behalf Of Cory Trese > |> Sent: Thursday, March 03, 2005 11:32 AM > |> To: htm...@li... > |> Subject: [htmltmpl] Sub-Classing HTML::Template v2.7 > |>=20 > |> Hello, > |>=20 > |> From some previous traffic on this list, Sam Tregar said: > |>=20 > |> |> Ultimately HTML::Template v2 doesn't offer much in terms=20 > |> of official=20 > |> |> support for sub-classes and extensions. That's a=20 > |> deficiency I intend=20 > |> |> to address in the perpetually-delayed v3. > |> =20 > |> I am trying to create a sub-class of HTML::Template that=20 > |> over-rides the 'param( )' method. The code below "works" --=20 > |> mostly -- but I have a feeling that I'm doing this all=20 > |> wrong. Does anyone have some advice or a link on=20 > |> HTML::Template v2 sub-classing? I looked at=20 > |> "HTML::Template::Expr" -- my code below is based, roughly,=20 > |> on this module. > |>=20 > |> My major questions are: > |>=20 > |> 1. How does a sub-class of HTML::Template construct itself? =20 > |> Should I over-ride 'new( )' or use something like 'make_new(=20 > |> )' to wrap 'new( )' > |> or 'SUPER::new( )'. > |>=20 > |> 2. What packages should my 'param( )' method be overridden=20 > |> in? More than HTML::Template? > |>=20 > |> The thing that doesn't work right: > |>=20 > |> 1. calls to 'param( )' seem to loose my 'i18n_strings'=20 > |> object -- it isn't ALWAYS present in 'options' when I call=20 > |> 'param( )', just most of the time. =20 > |>=20 > |> I _think_ that this is somehow related to some of the=20 > |> 'param( )' methods I'm using being in the class 'make_new(=20 > |> )' returns, and others, constructed somewhere else, but=20 > |> still using my 'param( )' method. I know that's confusing I=20 > |> haven't slept much in the past few days, sorry. > |>=20 > |> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> > |> package Service::Template; > |>=20 > |> use strict; > |> use vars qw($VERSION); > |>=20 > |> $VERSION =3D '0.01'; > |>=20 > |> use HTML::Template; > |>=20 > |> use base 'HTML::Template'; > |>=20 > |> sub make_new { > |> my $pkg =3D shift; > |> my $self; > |>=20 > |> # check hashworthyness > |> croak("Service::Template->new() called with odd number of=20 > |> option parameters - should be of the form option =3D> value") > |> if (@_ % 2); > |> my %options =3D @_; > |>=20 > |>=20 > |> # create an HTML::Template object, catch the results to keep = error > |> # message line-numbers helpful. > |> eval { > |> $self =3D $pkg->new(%options ); > |> }; > |> croak("Service::Template->new() : Error creating=20 > |> HTML::Template object > |> : $@") if $@; > |>=20 > |> $self->{options}->{i18n_strings} =3D $options{'i18n_strings'}; > |>=20 > |>=20 > |> return $self; > |> } > |>=20 > |> 1; > |>=20 > |> package HTML::Template; > |>=20 > |> sub param { > |> ... > |> } > |>=20 > |> 1; > |>=20 > |> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> > |>=20 > |> ************************************************************* > |> ********* > |> Confidentiality Notice > |> The information contained in this e-mail is confidential and=20 > |> intended for use only by the person(s) or organization=20 > |> listed in the address. If you have received this=20 > |> communication in error, please contact the sender at O'Neil=20 > |> & Associates, Inc., immediately. Any copying, dissemination,=20 > |> or distribution of this communication, other than by the=20 > |> intended recipient, is strictly prohibited. > |> ************************************************************* > |> ********* > |>=20 > |>=20 > |>=20 > |> ------------------------------------------------------- > |> SF email is sponsored by - The IT Product Guide Read honest=20 > |> & candid reviews on hundreds of IT Products from real users. > |> Discover which products truly live up to the hype. Start reading = now. > |> http://ads.osdn.com/?ad_id=3D6595&alloc_id=3D14396&op=3Dclick > |> _______________________________________________ > |> Html-template-users mailing list > |> Htm...@li... > |> https://lists.sourceforge.net/lists/listinfo/html-template-users > |>=20 >=20 > ********************************************************************** > Confidentiality Notice > The information contained in this e-mail is confidential and intended = for > use only by the person(s) or organization listed in the address. If = you have > received this communication in error, please contact the sender at = O'Neil & > Associates, Inc., immediately. Any copying, dissemination, or = distribution > of this communication, other than by the intended recipient, is = strictly > prohibited. > ********************************************************************** >=20 >=20 >=20 > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real = users. > Discover which products truly live up to the hype. Start reading now. > http://ads.osdn.com/?ad_id=3D6595&alloc_id=3D14396&op=3Dclick > _______________________________________________ > Html-template-users mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/html-template-users > |
From: Sam T. <sa...@tr...> - 2005-03-05 19:46:48
|
On Sat, 5 Mar 2005 bk...@de... wrote: > Data Grid PossiblitiesI am trying to obtain a data grid control for > my website. The data grid will be used to do quick sorts and > filters. I am not sure if there anything out there that is used with > Perl or some other solution. Javascript,.Net,etc.. I am looking for > a direction on if the datagrid should be client side vs server > side. The solution must be browser compatible with all major > browswers. Please give me some insight or point me in the right > direction. I would recommend hiring a programmer. Programmers know all about creating "data grids" (usually called "tables" or "spreadsheets") in their favorite languages. Virtually every computer programming system since the VisiCalc first hit the market has supported this concept! Alternately, if you would like to become a programmer yourself, I suggest you pick up a good beginning Perl book like "Learning Perl" and then something specific to UI programming like "CGI Programming in Perl". -sam |
From: <bk...@de...> - 2005-03-05 18:24:37
|
Data Grid PossiblitiesI am trying to obtain a data grid control for my website. The data grid will be used to do quick sorts and filters. I am not sure if there anything out there that is used with Perl or some other solution. Javascript,.Net,etc.. I am looking for a direction on if the datagrid should be client side vs server side. The solution must be browser compatible with all major browswers. Please give me some insight or point me in the right direction. Thanks, Brent |
From: Cory T. <Ct...@on...> - 2005-03-04 17:59:56
|
Hello, I have found the root of my problem! All the code below was centered around trying, and failing, to fully replace all instances of the HTML::Template 'param( )' method within our code-base. I thought that by building a sub-class and overriding param, I would be able to accomplish this. However, I was unable to override all calls to 'param( )' -- some within HTML::Template remained using the SUPER::param( ). I attempted to overwrite the package method, as seen below. This, however, doesn't actually work. So again, no dice. Until I found the following code in HTML::Template around Line #2112: $loop->[HTML::Template::LOOP::TEMPLATE_HASH]{$starts_at} = HTML::Template->_new_from_loop( This does not seem friendly to sub-classes ... I didn't see any references to this type of issue in Damian Conway's Object Oriented Perl book, but I found a solution that works great for my sub-classes. $loop->[HTML::Template::LOOP::TEMPLATE_HASH]{$starts_at} = ref( $self )->_new_from_loop( This way, the "_new_from_loop" call always occurs against the correct class -- HTML::Template or otherwise. I have no production code to test compatibility with HTML::Template::Expr so I cannot state if this type of change will work for everyone trying to sub-class HTML::Template. However, I do know that making this change caused my sub-classes to completely work and I am very happy about that. Sincerely, Cory Trese Lead Web Application Developer O'NEIL & ASSOCIATES, INC. 495 Byers Rd. Miamisburg, Ohio 45342-3662 Phone: (937) 865-0846 ext. 3038 Fax: (937) 865-5858 E-mail: [ct...@on...] |> -----Original Message----- |> From: htm...@li... |> [mailto:htm...@li...] On |> Behalf Of Cory Trese |> Sent: Thursday, March 03, 2005 11:32 AM |> To: htm...@li... |> Subject: [htmltmpl] Sub-Classing HTML::Template v2.7 |> |> Hello, |> |> From some previous traffic on this list, Sam Tregar said: |> |> |> Ultimately HTML::Template v2 doesn't offer much in terms |> of official |> |> support for sub-classes and extensions. That's a |> deficiency I intend |> |> to address in the perpetually-delayed v3. |> |> I am trying to create a sub-class of HTML::Template that |> over-rides the 'param( )' method. The code below "works" -- |> mostly -- but I have a feeling that I'm doing this all |> wrong. Does anyone have some advice or a link on |> HTML::Template v2 sub-classing? I looked at |> "HTML::Template::Expr" -- my code below is based, roughly, |> on this module. |> |> My major questions are: |> |> 1. How does a sub-class of HTML::Template construct itself? |> Should I over-ride 'new( )' or use something like 'make_new( |> )' to wrap 'new( )' |> or 'SUPER::new( )'. |> |> 2. What packages should my 'param( )' method be overridden |> in? More than HTML::Template? |> |> The thing that doesn't work right: |> |> 1. calls to 'param( )' seem to loose my 'i18n_strings' |> object -- it isn't ALWAYS present in 'options' when I call |> 'param( )', just most of the time. |> |> I _think_ that this is somehow related to some of the |> 'param( )' methods I'm using being in the class 'make_new( |> )' returns, and others, constructed somewhere else, but |> still using my 'param( )' method. I know that's confusing I |> haven't slept much in the past few days, sorry. |> |> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |> package Service::Template; |> |> use strict; |> use vars qw($VERSION); |> |> $VERSION = '0.01'; |> |> use HTML::Template; |> |> use base 'HTML::Template'; |> |> sub make_new { |> my $pkg = shift; |> my $self; |> |> # check hashworthyness |> croak("Service::Template->new() called with odd number of |> option parameters - should be of the form option => value") |> if (@_ % 2); |> my %options = @_; |> |> |> # create an HTML::Template object, catch the results to keep error |> # message line-numbers helpful. |> eval { |> $self = $pkg->new(%options ); |> }; |> croak("Service::Template->new() : Error creating |> HTML::Template object |> : $@") if $@; |> |> $self->{options}->{i18n_strings} = $options{'i18n_strings'}; |> |> |> return $self; |> } |> |> 1; |> |> package HTML::Template; |> |> sub param { |> ... |> } |> |> 1; |> |> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |> |> ************************************************************* |> ********* |> Confidentiality Notice |> The information contained in this e-mail is confidential and |> intended for use only by the person(s) or organization |> listed in the address. If you have received this |> communication in error, please contact the sender at O'Neil |> & Associates, Inc., immediately. Any copying, dissemination, |> or distribution of this communication, other than by the |> intended recipient, is strictly prohibited. |> ************************************************************* |> ********* |> |> |> |> ------------------------------------------------------- |> SF email is sponsored by - The IT Product Guide Read honest |> & candid reviews on hundreds of IT Products from real users. |> Discover which products truly live up to the hype. Start reading now. |> http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click |> _______________________________________________ |> Html-template-users mailing list |> Htm...@li... |> https://lists.sourceforge.net/lists/listinfo/html-template-users |> ********************************************************************** Confidentiality Notice The information contained in this e-mail is confidential and intended for use only by the person(s) or organization listed in the address. If you have received this communication in error, please contact the sender at O'Neil & Associates, Inc., immediately. Any copying, dissemination, or distribution of this communication, other than by the intended recipient, is strictly prohibited. ********************************************************************** |
From: Sam T. <sa...@tr...> - 2005-03-04 14:47:36
|
On Fri, 4 Mar 2005, [Windows-1251] =C3=EE=F0=FC=EA=E8=E9 =DE=F0=E8=E9 wrote= : > then $template->param('some_param') should be equal to 'value1' >=20 > ($query appears _earlier_ in associate) >=20 > but the fact is that $template->param('some_param') is equal to > 'value2' >=20 > am I mistaken? Sounds like a bug to me. I'll see if I can reproduce it later today. Of course, if you'd like to try to solve it I'd be happy to take a patch! -sam |
From: <hat...@tu...> - 2005-03-04 12:09:45
|
Hello html-template-users, may be I'm mistaken, but pod says: You can specify multiple objects to associate by passing an anonymous array to the associate option. They are searched for parameters in the order they appear: my $template = HTML::Template->new(filename => 'template.tmpl', associate => [$query, $other_obj]); as I understand, "They are searched for parameters in the order they appear" means that if we have $query->param(some_param => 'value1'); $other_obj->param(some_param => 'value2'); then $template->param('some_param') should be equal to 'value1' ($query appears _earlier_ in associate) but the fact is that $template->param('some_param') is equal to 'value2' am I mistaken? -- Best regards, Jury Gorky mailto:hat...@tu... |
From: Sam T. <sa...@tr...> - 2005-03-03 19:30:40
|
On Thu, 3 Mar 2005, Cory Trese wrote: > My major questions are: > > 1. How does a sub-class of HTML::Template construct itself? Should I > over-ride 'new( )' or use something like 'make_new( )' to wrap 'new( )' > or 'SUPER::new( )'. package HTML::Template::Awesomer; use base 'HTML::Template'; sub new { my $pkg = shift; my $self = $pkg->SUPER::new(@_); return $self; } Of course you can insert your own code before and after the call to SUPER::new() depending what you're trying to do. > 2. What packages should my 'param( )' method be overridden in? More > than HTML::Template? In your sub-class of course. Something like: sub param { my $self = shift; $self->SUPER::param(@_); } Of course you'll want to add code to implement your extension. You should never have this line in a sub-class: > package HTML::Template; That's going to actually overwrite (not override) a subroutine in the HTML::Template namespace. Have you read Damian Conway's Object Oriented Perl book? I highly recommend it for anyone serious about doing OO in Perl. -sam |
From: Cory T. <Ct...@on...> - 2005-03-03 16:32:41
|
Hello, From some previous traffic on this list, Sam Tregar said: |> Ultimately HTML::Template v2 doesn't offer much in terms of |> official support for sub-classes and extensions. That's a |> deficiency I intend to address in the perpetually-delayed v3. I am trying to create a sub-class of HTML::Template that over-rides the 'param( )' method. The code below "works" -- mostly -- but I have a feeling that I'm doing this all wrong. Does anyone have some advice or a link on HTML::Template v2 sub-classing? I looked at "HTML::Template::Expr" -- my code below is based, roughly, on this module. My major questions are: 1. How does a sub-class of HTML::Template construct itself? Should I over-ride 'new( )' or use something like 'make_new( )' to wrap 'new( )' or 'SUPER::new( )'. 2. What packages should my 'param( )' method be overridden in? More than HTML::Template? The thing that doesn't work right: 1. calls to 'param( )' seem to loose my 'i18n_strings' object -- it isn't ALWAYS present in 'options' when I call 'param( )', just most of the time. I _think_ that this is somehow related to some of the 'param( )' methods I'm using being in the class 'make_new( )' returns, and others, constructed somewhere else, but still using my 'param( )' method. I know that's confusing I haven't slept much in the past few days, sorry. >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> package Service::Template; use strict; use vars qw($VERSION); $VERSION = '0.01'; use HTML::Template; use base 'HTML::Template'; sub make_new { my $pkg = shift; my $self; # check hashworthyness croak("Service::Template->new() called with odd number of option parameters - should be of the form option => value") if (@_ % 2); my %options = @_; # create an HTML::Template object, catch the results to keep error # message line-numbers helpful. eval { $self = $pkg->new(%options ); }; croak("Service::Template->new() : Error creating HTML::Template object : $@") if $@; $self->{options}->{i18n_strings} = $options{'i18n_strings'}; return $self; } 1; package HTML::Template; sub param { ... } 1; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ********************************************************************** Confidentiality Notice The information contained in this e-mail is confidential and intended for use only by the person(s) or organization listed in the address. If you have received this communication in error, please contact the sender at O'Neil & Associates, Inc., immediately. Any copying, dissemination, or distribution of this communication, other than by the intended recipient, is strictly prohibited. ********************************************************************** |
From: Sam T. <sa...@tr...> - 2005-03-02 16:45:36
|
On Tue, 1 Mar 2005, Robert Ferney wrote: > I envision something like > <TMPL_SCOPE NAME="other"> > <div style="color:<TMPL_VAR color>;"><TMPL_VAR name="bar"></div> > </TMPL_SCOPE> > > this would be a slight variation on the TMPL_LOOP with the main > difference being that there is only one of them, rather than a list of > them.. ie.. it's going to get a HASH ref instead of a LIST ref that > contains HASH refs. > > I'm looking at the code now, I don't think this should be *too* > difficult. but any time you have to grok someone elses code it is > going to take longer than it would someone who is already familiar > with it. I think this could be done relatively easily in a sub-class using filter and an overridden param(). Here's how: - Your custom filter parses the SCOPEs and find VARs inside them. It alters their names to include the SCOPE name. For example, a var named "foo" inside a scope called "bar" might be "foo...bar". - Your custom param() looks for hash-refs and similarly modifies their names into "scope...var" format. - For extra credit, catch exceptions and fix the names so they don't expose the grotty internals to the end user. -sam |
From: Robert F. <cap...@gm...> - 2005-03-02 02:47:35
|
If you have a datastructure that looks like { foo=>1234, bar=>"iron", other=>{ color=>"orange", foo=>3.14, bar=>"brass" }, } it would be nice to have a way to access the elements of other ... I envision something like <TMPL_SCOPE NAME="other"> <div style="color:<TMPL_VAR color>;"><TMPL_VAR name="bar"></div> </TMPL_SCOPE> this would be a slight variation on the TMPL_LOOP with the main difference being that there is only one of them, rather than a list of them.. ie.. it's going to get a HASH ref instead of a LIST ref that contains HASH refs. I'm looking at the code now, I don't think this should be *too* difficult. but any time you have to grok someone elses code it is going to take longer than it would someone who is already familiar with it. -rob. |
From: James K. <jk...@ve...> - 2005-02-27 14:11:52
|
On Feb 26, 2005, Sam Tregar wrote: > > On Sat, 26 Feb 2005, James Keenan wrote: > [snip] > >> Has anyone else encountered these problems and developed a workaround? > > The best workaround is to just switch to the file_cache. In most > cases it's just as fast as shared_cache due to the OS caching file > access and it's a heck of a lot easier to work with (no arbitrary > limits, no need for special tools to clear the cache, etc). > > -sam ... and Cees Hek wrote: > > I would seconds Sam's suggestion here. The shared memory caches are > not > really worth the trouble, and are actually surprisingly slow. If it is > absolutely necesary for the cache to be in memory then setup an > in-memory filesystem (not sure how to do that on OSX). However, it is > often best to just let the OS handle the file system caching directly. > The OS is very efficient at keeping the most often accessed files in > memory for quick access. > Thanks, Sam and Cees for such a quick response. I should perhaps clarify that my interest in solving this problem was not to maximize H::T's speed. Rather, as part of the Phalanx Q.A. process (http://qa.perl.org/phalanx), I'm working with some of my fellow hackers from Perl Seminar NY on H::T. One of the things we like to do is to improve the extent to which a given module's test suite provides coverage for the module's code. Having all of a module's features installed is important here. Fortunately, besides a couple of Macs we have Linux, FreeBSD and Windows boxes available, so we'll probably be able to get the shared cache feature running on one of them and be able to take a look at the test coverage in that area. Thanks again. Jim Keenan |
From: Cees H. <ce...@si...> - 2005-02-26 17:57:53
|
Sam Tregar wrote: > The best workaround is to just switch to the file_cache. In most > cases it's just as fast as shared_cache due to the OS caching file > access and it's a heck of a lot easier to work with (no arbitrary > limits, no need for special tools to clear the cache, etc). I would seconds Sam's suggestion here. The shared memory caches are not really worth the trouble, and are actually surprisingly slow. If it is absolutely necesary for the cache to be in memory then setup an in-memory filesystem (not sure how to do that on OSX). However, it is often best to just let the OS handle the file system caching directly. The OS is very efficient at keeping the most often accessed files in memory for quick access. Cheers, Cees |
From: Sam T. <sa...@tr...> - 2005-02-26 16:59:44
|
On Sat, 26 Feb 2005, James Keenan wrote: > But the other is IPC::ShareLite (v0.06 or later) > (http://search.cpan.org/~maurice/IPC-ShareLite-0.09/). This module has XS > code (there be goblins). My attempt to install it on Darwin failed. I can't > say why, but perhaps this quotation from the IPC::ShareLite README is > relevant: "Your operating system must support SysV IPC (shared memory and > semaphores) in order to use this module." I guess this is your real problem, right? I suppose you should take it up with the maintainer of IPC::ShareLite. Be sure to include the full error you received when you tried to compile. > Has anyone else encountered these problems and developed a workaround? The best workaround is to just switch to the file_cache. In most cases it's just as fast as shared_cache due to the OS caching file access and it's a heck of a lot easier to work with (no arbitrary limits, no need for special tools to clear the cache, etc). -sam |
From: James K. <jk...@ve...> - 2005-02-26 15:33:56
|
I was unable to locate a discussion of this problem in the list archives (http://sourceforge.net/mailarchive/forum.php?forum_id=9830), so I would like to pose it to the list. Recently I installed HTML::Template on my iBook (Mac OS X 10.3 Darwin). In my first attempt, I elected *not* to install the shared cache feature. The package installed and tested properly, with 2 tests which called the shared cache feature being properly skipped. I then tried to reinstall *with* the shared cache feature by answering 'yes' at every prompt called by 'make'. Here I ran into considerable problems, as the shared cache feature has dependencies which are *not* listed in Makefile.PL. These dependencies are 'require'-ed rather than 'use'-d and the module puts these requires in 'eval' blocks. The modules required on the fly which gave me problems were: Gtop: required for the memory_debug feature; documented at line 670; code begins at line 1038. Gtop (http://search.cpan.org/~stas/GTop-0.14/) is described as Perl interface to libgtop. libgtop is a library not found on all OSes. I tried to understand its relationship to HTML::Template but noted these further problems: (1) The POD is all screwed up (e.g., http://search.cpan.org/~stas/GTop-0.14/Makefile.PL). The maintainer has responded and written a patch, but it will only get up to CPAN when the next version of the module is released. (2) The current version of GTop has not been extensively tested by testers.cpan -- only two testers have run it -- and it has failed all those tests. This suggests that the foundations of HTML::Template's memory_debug feature are shaky. IPC::SharedCache: required for the shared_cache feature; documented at line 524, 665; code begins at line 1060, 1067. IPC::SharedCache (http://search.cpan.org/~samtregar/IPC-SharedCache-1.3/) was also written by Sam Tregar, author of HTML::Template. IPC::SharedCache in turn has dependencies listed in its Makefile.PL. One is IPC::SysV, a module with which I was previously not acquainted, has been core since perl 5.005. But the other is IPC::ShareLite (v0.06 or later) (http://search.cpan.org/~maurice/IPC-ShareLite-0.09/). This module has XS code (there be goblins). My attempt to install it on Darwin failed. I can't say why, but perhaps this quotation from the IPC::ShareLite README is relevant: "Your operating system must support SysV IPC (shared memory and semaphores) in order to use this module." I tried to install the full-featured version of HTML::Template first via the CPAN.pm automated process, then by manually installing each dependency. I never succeeded in installing either Gtop or IPC::ShareLite. Consequently, I have only the non-shared cache version of HTML::Template to work with. Has anyone else encountered these problems and developed a workaround? Thanks for reading this far! Jim Keenan |
From: Sam T. <sa...@tr...> - 2005-02-25 13:45:42
|
On Fri, 25 Feb 2005, Thomas Gutzler wrote: > it looks a bit dodgy to me, that > <TMPL_IF EXPR="(foo eq 'bar') || (foo eq 'bar2')"> > works well but > <TMPL_IF EXPR="(foo eq 'bar') || (foo eq 'bar2') || (foo eq 'bar3')"> > has to be written as > <TMPL_IF EXPR="((foo eq 'bar') || (foo eq 'bar2')) || (foo eq 'bar3')"> > to get it working. > Is that a known bug or meant to be as a feature? :) It's a known bug - one that I nearly solved last month but didn't finish. You can read about it here: http://perlmonks.org/?node_id=414823 I think jryan's suggestion is correct and seemed to be working well... and then I got distracted. I hope to get back to it sometime soon. -sam |
From: Thomas G. <gi...@gm...> - 2005-02-25 11:11:13
|
Hi, it looks a bit dodgy to me, that <TMPL_IF EXPR="(foo eq 'bar') || (foo eq 'bar2')"> works well but <TMPL_IF EXPR="(foo eq 'bar') || (foo eq 'bar2') || (foo eq 'bar3')"> has to be written as <TMPL_IF EXPR="((foo eq 'bar') || (foo eq 'bar2')) || (foo eq 'bar3')"> to get it working. Is that a known bug or meant to be as a feature? :) Cheers, Tom -- Play Rogue, visit exotic locations, meet strange creatures and kill them. |
From: Timm M. <tm...@ag...> - 2005-02-23 21:23:08
|
At 03:12 PM 2/23/2005, Keith Jackson wrote: <> >If I put a statement in my perl code just before the $t->output which >dumps the contents of $t->param, > >map("$_ = ".Dumper($template->param($_)) > >save that output as a baseline. Then for testing repeat the process but >now compare the values to the baseline data. I wrote HTML::Template::Dumper to do basically the same thing. It is designed to use a verity of dumping formats (Data::Dumper, YAML, whatever). You need to make some minimal modifications to the program (replace "use HTML::Template" with "use HTML::Template::Dumper" and set an output format) to run the tests--these should be significantly less than modifications to reinvent what HTML::Template::Dumper already does. Timm Murray IT Web Asst. ASA-CSSA-SSSA 677 S Segoe Rd. Madison, WI 53711-1086 Phone: 608-268-4944 Fax: 608-273-2021 www.agronomy.org www.crops.org www.soils.org |
From: Keith J. <kja...@ey...> - 2005-02-23 21:12:55
|
I am exploring ways to implement testing on a large dynamic web site. We use MySQL, perl and H::T for all dynamic content. I've explored some tools that check the HTML pages or the http data stream and compare them to a base set of data. I've also used Test::More for some basic testing to make sure data is saved and retrieved properly. Now I'm thinking that what I really want to look at is the data being passed to the template under various conditions. The templates themselves need to be tested too but they are rarely the source of problems. If I put a statement in my perl code just before the $t->output which dumps the contents of $t->param, map("$_ = ".Dumper($template->param($_)) save that output as a baseline. Then for testing repeat the process but now compare the values to the baseline data. Does anyone have any experience with testing in this way. Obviously this is only part of the testing. Thanks in advance. -- Keith Jackson <kja...@ey...> |