> So I guess that's a roundabout way of saying that it's now in TT3. :-) > > For the sake of completeness, I suppose we should also have a FILE > directive. > > [% FILE foo LINE 42 %] > > And some way of inserting the file/line values back into a template. > > Hello World from [% FILE %] line [% LINE %] > > There's a few issues to think about there, but in principle I'm all for it.
I was on my way to add it to Template::Alloy - but I hit the few issues portion. I like the LINE directive. I think it is great. There is good utility there. I think to extend it a little further, it should be able to take the value of a variable or an expression there as well that can be evaluated at compile time. The FILE directive seems to have a bit more baggage. If you want to change the file name for use inside the current template, well - you can either use a different name, or use [% META name %] or [% template.name %]. If you want a different name to be used out in the cache - well that is certainly possible, but then you end up caching a "file" that you didn't ask for. Maybe the FILE name is only used when throwing errors - I can sort of see that one - but not too much. Either way, I think META name and template.name almost handle everything. But then there is a further issue. The words FILE and LINE and particularly file and line are used extensively in existing templates. I don't think that the proposed directives add enough functionality to warrant making them reserved words. Rather than add FILE and LINE, I would greatly suggest adding the CONFIG directive that was proposed some time ago but seemed to be warnocked. The CONFIG directiveis already being used with great advantage in Template::Alloy. The FILE and LINE directives seem to fall pretty much in the scope of CONFIG. So you'd have [% CONFIG FILE => 'foo', LINE => 42 %]. And You are on line [% CONFIG LINE %]. I think that it is some what more descriptive than setting [% LINE 42 %]. I have actually found the CONFIG directive to be "encompassing" enough that the TAGS directive ought to be deprecated in favor of using [% CONFIG TAGS => ['[%', '%]'] %] or [% CONFIG TAGS => 'html' %]. I think that using CONFIG to set configuration items is much more consistent, it has better huffmanization (in the Perl sense of the word), and it keeps from adding new, potentially conflicting DIRECTIVES, anytime a new configuration feature is added. So - to sum up... 1) I'd like to see what scope the FILE directive would really have. 2) I'd propose not adding them as directives, but as part of the CONFIG directive. Paul _______________________________________________ templates mailing list [email protected] http://lists.template-toolkit.org/mailman/listinfo/templates
