Thread: [htmltmpl] die_on_missing_params
Brought to you by:
samtregar
From: Joshua <jo...@hi...> - 2007-05-30 20:47:58
|
Greetings. (I'm sorry if I double posted this. However, the first time I sent it, I was not subscribed to the mailing list, so I don't think it went through.) I find the "die_on_bad_params => 1" to be a very useful feature. Setting it to 0 is kind of like debugging Perl without "use strict;". However, die_on_bad_params only does half the job. It dies if I try to set non-existent vars, but it does nothing if I forget to set an existing var. Is there a way (such as a die_on_missing_params option) that I can turn on some such warning system? (Perhaps there are some extensions to HTML::Template that do this?) Any help is appreciated. Josh "Ua" Ball |
From: Mathew R. <mat...@ne...> - 2007-11-01 04:08:47
|
Hi list, Sometime ago I posted a message regarding having an updated H::T which had support for "die_on_missing_params" - a feature requested by Joshua Ball. As a side effect of a machine update, I have managed to loose the patch... If Joshua is still on the list, could you please email me updated module. cheers, Mathew Robertson |
From: Mathew R. <mat...@ne...> - 2007-05-31 07:08:49
|
Short answer: no there isn't such a feature. However I do have a patch I use to add this ability - with one caveat... the patch changes the behaviour such that if your code never implemented: $ht->param(parm_name => undef); but did rely on the undef'ness of param_name, then your code would need the above line added where appropriate. I found that I would often write: $ht->param(param_name => get_something()); so param_name would be explicitely set to undef, and so the patch works for me. Mathew Robertson Joshua wrote: > Greetings. > > (I'm sorry if I double posted this. However, the first time I sent it, I was > not subscribed to the mailing list, so I don't think it went through.) > > I find the "die_on_bad_params => 1" to be a very useful feature. Setting it > to 0 is kind of like debugging Perl without "use strict;". > > However, die_on_bad_params only does half the job. It dies if I try to set > non-existent vars, but it does nothing if I forget to set an existing var. > Is there a way (such as a die_on_missing_params option) that I can turn on > some such warning system? (Perhaps there are some extensions to > HTML::Template that do this?) > > Any help is appreciated. > > Josh "Ua" Ball > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Html-template-users mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/html-template-users > |
From: Joshua B. <sci...@gm...> - 2007-05-31 14:25:27
|
Hi Mathew, (This is the same Josh as @highgatecross. My e-mail there is down, so I subscribed from another address. :->) That's exactly what I'm looking for. I'm dealing with legacy code which has highly nested includes in the templates. From what I've been able to tell, I don't think the original coder relied on implicit undefness. My main concern is that I want to be warned if there are subs that I ought to be calling (to fill in template parameters in things like headers and footers). It's especially easy to overlook when the tmpl_var's are used for "hidden" information, like URLs and hidden form fields. Where can I find your patch? Thanks again, Josh "Ua" Ball On 5/31/07, Mathew Robertson <mat...@ne...> wrote: > > Short answer: no there isn't such a feature. > > However I do have a patch I use to add this ability - with one caveat... > the patch changes the behaviour such that if your code never implemented: > > $ht->param(parm_name => undef); > > but did rely on the undef'ness of param_name, then your code would need the > above line added where appropriate. I found that I would often write: > > $ht->param(param_name => get_something()); > > so param_name would be explicitely set to undef, and so the patch works for > me. > > Mathew Robertson > > > > > Joshua wrote: > Greetings. > > (I'm sorry if I double posted this. However, the first time I sent it, I was > not subscribed to the mailing list, so I don't think it went through.) > > I find the "die_on_bad_params => 1" to be a very useful feature. Setting it > to 0 is kind of like debugging Perl without "use strict;". > > However, die_on_bad_params only does half the job. It dies if I try to set > non-existent vars, but it does nothing if I forget to set an existing var. > Is there a way (such as a die_on_missing_params option) that I can turn on > some such warning system? (Perhaps there are some extensions to > HTML::Template that do this?) > > Any help is appreciated. > > Josh "Ua" Ball > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Html-template-users mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/html-template-users > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Html-template-users mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/html-template-users > > |
From: Mathew R. <mat...@ne...> - 2007-05-31 23:11:33
|
Hi List, Patch sent directly to Josh so as to avoid the list noise. If people are interested, I will post it (and the test cases). cheers, Mathew Joshua Ball wrote: > Hi Mathew, > > (This is the same Josh as @highgatecross. My e-mail there is down, so > I subscribed from another address. :->) > > That's exactly what I'm looking for. I'm dealing with legacy code > which has highly nested includes in the templates. From what I've been > able to tell, I don't think the original coder relied on implicit > undefness. My main concern is that I want to be warned if there are > subs that I ought to be calling (to fill in template parameters in > things like headers and footers). It's especially easy to overlook > when the tmpl_var's are used for "hidden" information, like URLs and > hidden form fields. > > Where can I find your patch? > > Thanks again, > Josh "Ua" Ball > > On 5/31/07, Mathew Robertson <mat...@ne...> wrote: > >> Short answer: no there isn't such a feature. >> >> However I do have a patch I use to add this ability - with one caveat... >> the patch changes the behaviour such that if your code never implemented: >> >> $ht->param(parm_name => undef); >> >> but did rely on the undef'ness of param_name, then your code would need the >> above line added where appropriate. I found that I would often write: >> >> $ht->param(param_name => get_something()); >> >> so param_name would be explicitely set to undef, and so the patch works for >> me. >> >> Mathew Robertson >> >> >> >> >> Joshua wrote: >> Greetings. >> >> (I'm sorry if I double posted this. However, the first time I sent it, I was >> not subscribed to the mailing list, so I don't think it went through.) >> >> I find the "die_on_bad_params => 1" to be a very useful feature. Setting it >> to 0 is kind of like debugging Perl without "use strict;". >> >> However, die_on_bad_params only does half the job. It dies if I try to set >> non-existent vars, but it does nothing if I forget to set an existing var. >> Is there a way (such as a die_on_missing_params option) that I can turn on >> some such warning system? (Perhaps there are some extensions to >> HTML::Template that do this?) >> >> Any help is appreciated. >> >> Josh "Ua" Ball >> >> >> >> ------------------------------------------------------------------------- >> This SF.net email is sponsored by DB2 Express >> Download DB2 Express C - the FREE version of DB2 express and take >> control of your XML. No limits. Just data. Click to get it now. >> http://sourceforge.net/powerbar/db2/ >> _______________________________________________ >> Html-template-users mailing list >> Htm...@li... >> https://lists.sourceforge.net/lists/listinfo/html-template-users >> >> >> ------------------------------------------------------------------------- >> This SF.net email is sponsored by DB2 Express >> Download DB2 Express C - the FREE version of DB2 express and take >> control of your XML. No limits. Just data. Click to get it now. >> http://sourceforge.net/powerbar/db2/ >> _______________________________________________ >> Html-template-users mailing list >> Htm...@li... >> https://lists.sourceforge.net/lists/listinfo/html-template-users >> >> >> > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Html-template-users mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/html-template-users > |
From: Joshua B. <sci...@gm...> - 2007-06-01 14:00:36
|
Thanks! I'll start using it and let you know if I run into any problems. On 5/31/07, Mathew Robertson <mat...@ne...> wrote: > > Hi List, > > Patch sent directly to Josh so as to avoid the list noise. If people are > interested, I will post it (and the test cases). > > cheers, > Mathew > > > > Joshua Ball wrote: > Hi Mathew, > > (This is the same Josh as @highgatecross. My e-mail there is down, so > I subscribed from another address. :->) > > That's exactly what I'm looking for. I'm dealing with legacy code > which has highly nested includes in the templates. From what I've been > able to tell, I don't think the original coder relied on implicit > undefness. My main concern is that I want to be warned if there are > subs that I ought to be calling (to fill in template parameters in > things like headers and footers). It's especially easy to overlook > when the tmpl_var's are used for "hidden" information, like URLs and > hidden form fields. > > Where can I find your patch? > > Thanks again, > Josh "Ua" Ball > > On 5/31/07, Mathew Robertson > <mat...@ne...> wrote: > > > Short answer: no there isn't such a feature. > > However I do have a patch I use to add this ability - with one caveat... > the patch changes the behaviour such that if your code never implemented: > > $ht->param(parm_name => undef); > > but did rely on the undef'ness of param_name, then your code would need the > above line added where appropriate. I found that I would often write: > > $ht->param(param_name => get_something()); > > so param_name would be explicitely set to undef, and so the patch works for > me. > > Mathew Robertson > > > > > Joshua wrote: > Greetings. > > (I'm sorry if I double posted this. However, the first time I sent it, I was > not subscribed to the mailing list, so I don't think it went through.) > > I find the "die_on_bad_params => 1" to be a very useful feature. Setting it > to 0 is kind of like debugging Perl without "use strict;". > > However, die_on_bad_params only does half the job. It dies if I try to set > non-existent vars, but it does nothing if I forget to set an existing var. > Is there a way (such as a die_on_missing_params option) that I can turn on > some such warning system? (Perhaps there are some extensions to > HTML::Template that do this?) > > Any help is appreciated. > > Josh "Ua" Ball > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Html-template-users mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/html-template-users > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Html-template-users mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/html-template-users > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Html-template-users mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/html-template-users > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Html-template-users mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/html-template-users > > |
From: Joshua B. <sci...@gm...> - 2007-06-14 14:27:38
|
Hi list, I am happy to say that I haven't run into any problems using Mathew's patch. It's exactly what I wanted/needed! Thanks! I do have a feature request though: Currently if I leave out 2 params, it only notifies me that one of them is missing. It would be nice if I was told when both were missing. This issue applies to die_on_bad_params as well, but it's slightly more subtle, because the dying point is different. With die_on_bad_params, you die as soon as the param is set, so no list of bad_params could accumulate. (unless of course you wait until $template->output() to die). Also, I've noticed that if I comment out a <tmpl_var ...> in the template file, die_on_missing_params still thinks I should set it. Likewise, if I set a parameter that has been commented out, die_on_bad_params remains silent. Perhaps this is the intended behavior... after all, somebody may want to fill in html comments from the code. And adding a new comment syntax to template files would detract from it's great simplicity. Besides, commenting out code is considered bad practice anyway, isn't it? :) Again, thanks for the patch! Josh "Ua" Ball On 5/31/07, Mathew Robertson <mat...@ne...> wrote: > > Hi List, > > Patch sent directly to Josh so as to avoid the list noise. If people are > interested, I will post it (and the test cases). > > cheers, > Mathew > > > > Joshua Ball wrote: > Hi Mathew, > > (This is the same Josh as @highgatecross. My e-mail there is down, so > I subscribed from another address. :->) > > That's exactly what I'm looking for. I'm dealing with legacy code > which has highly nested includes in the templates. From what I've been > able to tell, I don't think the original coder relied on implicit > undefness. My main concern is that I want to be warned if there are > subs that I ought to be calling (to fill in template parameters in > things like headers and footers). It's especially easy to overlook > when the tmpl_var's are used for "hidden" information, like URLs and > hidden form fields. > > Where can I find your patch? > > Thanks again, > Josh "Ua" Ball > > On 5/31/07, Mathew Robertson > <mat...@ne...> wrote: > > > Short answer: no there isn't such a feature. > > However I do have a patch I use to add this ability - with one caveat... > the patch changes the behaviour such that if your code never implemented: > > $ht->param(parm_name => undef); > > but did rely on the undef'ness of param_name, then your code would need the > above line added where appropriate. I found that I would often write: > > $ht->param(param_name => get_something()); > > so param_name would be explicitely set to undef, and so the patch works for > me. > > Mathew Robertson > > > > > Joshua wrote: > Greetings. > > (I'm sorry if I double posted this. However, the first time I sent it, I was > not subscribed to the mailing list, so I don't think it went through.) > > I find the "die_on_bad_params => 1" to be a very useful feature. Setting it > to 0 is kind of like debugging Perl without "use strict;". > > However, die_on_bad_params only does half the job. It dies if I try to set > non-existent vars, but it does nothing if I forget to set an existing var. > Is there a way (such as a die_on_missing_params option) that I can turn on > some such warning system? (Perhaps there are some extensions to > HTML::Template that do this?) > > Any help is appreciated. > > Josh "Ua" Ball > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Html-template-users mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/html-template-users > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Html-template-users mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/html-template-users > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Html-template-users mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/html-template-users > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Html-template-users mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/html-template-users > > |
From: Mathew R. <mat...@ne...> - 2007-06-15 02:38:10
|
Hi List, [ Eventually I will post a patch to H::T to a webpage, in the meantime I have sent an update version directly to Joshua. If others are interested in this patch, shoot me a email. ] > I am happy to say that I haven't run into any problems using Mathew's > patch. It's exactly what I wanted/needed! Thanks! > Thats good. > I do have a feature request though: > > Currently if I leave out 2 params, it only notifies me that one of > them is missing. It would be nice if I was told when both were > missing. > Hadn't considered that. The existing coding practice within H::T is that is croak's immediately on error conditions. However, in the case of this option, adding support for accumulating the errors is pretty trivial, so I did. > This issue applies to die_on_bad_params as well, but it's slightly > more subtle, because the dying point is different. With > die_on_bad_params, you die as soon as the param is set, so no list of > bad_params could accumulate. (unless of course you wait until > $template->output() to die). > > Also, I've noticed that if I comment out a <tmpl_var ...> in the > template file, die_on_missing_params still thinks I should set it. > Likewise, if I set a parameter that has been commented out, > die_on_bad_params remains silent. Perhaps this is the intended > behavior... after all, somebody may want to fill in html comments from > the code. And adding a new comment syntax to template files would > detract from it's great simplicity. Besides, commenting out code is > considered bad practice anyway, isn't it? :) > Some browsers support conditional compilation/execution, which means that HTML comments are actually parsed. In fact, since HTML comments are true-dinks DOM elements, there are some javascript libraries that parse the comment block to enable extra features, while being old-browser compatible. So yes, you want TMPL_xxx parsed inside HTML comments. If you really want to comment out a TMPL_VAR, you could try unsetting "strict" so that you can do: <TMPL_VAR name> => <TMPL_ZUH name> Or if you need to comment out a HTML block, you can use a H::T filter such as: sub tmpl_comment { my $filter = sub { my $text_ref = shift; my $match = qr/<(?:\!--\s*)?[Tt][Mm][Pp][Ll]_[Cc][Oo][Mm][Mm][Ee][Nn][Tt]\s*(?:--)?>.*?<(?:\!--\s*)?\/[Tt][Mm][Pp][Ll]_[Cc][Oo][Mm][Mm][Ee][Nn][Tt]\s*(?:--)?>/s; $$text_ref =~ s/$match//g; }; return $filter; } $ht = HTML::Template->new(...., filter => tmpl_comment,...); <TMPL_COMMENT> ... some <a...> html </a> </TMPL_COMMENT> Regards, Mathew Robertson |
From: Robert H. <si...@gm...> - 2007-06-01 11:45:55
|
Joshua wrote: > Greetings. > > (I'm sorry if I double posted this. However, the first time I sent it, I was > not subscribed to the mailing list, so I don't think it went through.) > > I find the "die_on_bad_params => 1" to be a very useful feature. Setting it > to 0 is kind of like debugging Perl without "use strict;". > > However, die_on_bad_params only does half the job. It dies if I try to set > non-existent vars, but it does nothing if I forget to set an existing var. > Is there a way (such as a die_on_missing_params option) that I can turn on > some such warning system? (Perhaps there are some extensions to > HTML::Template that do this?) > > Any help is appreciated. > Maybe something as simple as a patch to allow: die_on_unset_vars => 1 Robert |