On 4/25/07, Clinton Gormley <[EMAIL PROTECTED]> wrote:
One of the issues that I am finding in my templates as they become more complex, is the problem of namespace collision, ie just remembering what variables I have used where, and whether using this variable name is going to cause problems at a distance.
What's causing you to need to define variables in your template? If it's small, temporary variables for use in parameterized macros and the like, a naming convention is a reasonable solution. Another possibility is to use one top-level namespace for things you pass to process() and another for things you use as temporary parameters in templates, e.g. stash.* and local.*. That narrows down the possibility of collision and makes it pretty manageable.
I use PROCESS rather than INCLUDE to process other blocks, because "I have read" that there is a significant performance cost to localising all the variables. How bad is this?
It's slower than most operations in TT if you have lots of includes. Maybe it doesn't matter in your application. Try a quick regex s/PROCESS/INCLUDE/ and DProf it to know for sure.
The alternative would be to use my own namespaces in naming variables, as in : main.title.xyz How does this perform in comparison?
I expect that will be quite a bit better than localizing the stash. - Perrin _______________________________________________ templates mailing list [email protected] http://lists.template-toolkit.org/mailman/listinfo/templates
