[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Eliminating the need to walk the variables hash passed to templates using Template::Stash?



Hi all,


Each template output format has some kind of variable preprocessor (see https://github.com/ledgersmb/LedgerSMB/blob/master/lib/LedgerSMB/Template/LaTeX.pm#L76) which walks the entire hash of values passed to the template to escape the values appropriately for the given output format (e.g. HTML escapes & to & et all.).

As can be seen by the reported problem running LedgerSMB on mod_perl2, this is error prone: the walker ran into an object of a type that was unknown to it (Apache2::RequestRec). Additionally it seems rather inefficient to walk the entire hash and encode all values when we usually don't use all values anyway.

Some months ago, I found that we can hook into Template Toolkit's variable-value-getter: http://template-toolkit.org/docs/modules/Template/Stash.html#method_get . When we wrap the 'get'/'set' methods, it seems we can be much more efficient at encoding. Also, since the Apache2::RequestRec value was stored in a field which isn't ever being accessed, running on mod_perl2 would have worked out of the box.


I'm thinking we should move to cleaning up variable escaping in the Template/*.pm format files and use the Stash wrapper. Comments?

--
Bye,

Erik.

http://efficito.com -- Hosted accounting and ERP.
Robust and Flexible. No vendor lock-in.
------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
_______________________________________________
Ledger-smb-devel mailing list
..hidden..
https://lists.sourceforge.net/lists/listinfo/ledger-smb-devel