[cgiapp] proposal for new cgiapp hook: loaded_html_tmpl

Mark Stosberg mark at summersault.com
Mon Oct 26 11:51:12 EDT 2009


Michael --

> Here's a new proposal for solving the multiple template parsing problem
> when die_on_bad_params is enabled.  Add another callback to
> CGI::Application:  
> 
>     loaded_html_tmpl
> 
> This gets called with the newly created template object before it gets
> returned to the user.  CAP::AnyTemplate and CAP::TT would not call this
> hook.
> 
> Plugins wishing to automatically pass variables to templates would do
> the following:
> 
>   * hook the 'load_tmpl' callback
>     - if html_tmpl_class isa 'HTML::Template' then return.  
>     - Otherwise, add parameters to $tmpl_params
> 
>   * hook the 'loaded_html_template' callback
>     - return unless html_tmpl_class isa 'HTML::Template' 
>     - check $ht_params for die_on_bad_params (default to 1)
>     - if die_on_bad_params is enabled, use HTML::Template's query method
>       to determine whether or not it is safe to add the parameter.
>     - if it is safe, add the parameter via $tmpl->param();
> 
> I don't know how many people use die_on_bad_params, so I don't
> know how worth it it is to modify the core.
> 
> However, this hook would improve performance for users of
> die_on_bad_params when using plugins that automatically add
> template values, and it would greatly simplify the code required in
> each of these plugins.

How would your propose to deal with the "HTML::Template-like" modules that do not pass the "isa HTML::Template" test but are generally compatible? 

Could we test for the features we need instead of the classes they come from? 

   Mark

-- 
 . . . . . . . . . . . . . . . . . . . . . . . . . . . 
   Mark Stosberg            Principal Developer  
   mark at summersault.com     Summersault, LLC     
   765-939-9301 ext 202     database driven websites
 . . . . . http://www.summersault.com/ . . . . . . . .




More information about the cgiapp mailing list