Buddy Burden wrote: > Does any of that make sense? Yes.
> is there a whole better way that I'm just not seeing? No. While I'm sure there's some way to do it (although I'm not sure what it is off the top of my head), I don't think there's any easy way to do it. But it is something I've been addressing for TT3. Firstly we're going to have proper support for relative paths. [% INCLUDE ../header %] If this is in the foo/bar/baz.tt template, then it refers to foo/header. This will allow you to better navigate around your template/data model. The current "relative-means-relative-to-the- INCLUDE_PATH root" behaviour is as good as useless (although I'd be interested to hear if anyone is currently relying on its behaviour). Second, we're going to have syntax-level support for URI-like paths. You'll be able to specify a path wherever you can currently specify a variable: [% somefile = ../header %] [% webpage = http://somewhere.com/a/random/page.html %] At the very least, you'll be able to query data or metadata from a separate template or other file, via an intermediate variable, e.g. [% somefile.title %] [% webpage.author.name.last %] And we're _probably_ going to support path fragments to allow us to access data or metadata from the file/resource directly: [% ../header#title %] [% http://somewhere.com/a/random/page.html#author.name.last %] I say "probably" because the use of '#' as the fragment marker conflicts with the use of '#' as a comment marker in TT. We would have to special-case the use of '#' in a path like the above: [% http://example.com/blah.html#this_is_a_fragment %] [% http://example.com/blah.html #this_is_a_comment %] I'm wary about special-casing, especially when it comes down to significant whitespace. But having language-level support for URIs would, I think, be a very useful thing. Finally, there will be the capability to define custom providers for different resources, based on filename, location, extension, or whatever else you can imagine. This is the back-end magic that turns a URI into the right kind of data object: a template, file object, web page object, XML DOM, other data structure, etc. For example, you could hook in an XML provider to load XML files into the right kind of data structure for you (e.g. using XML::Simple) data/widget.xml: <product id="widget123"> <description>This is the all-new Widget-123</description> <price>7.99</price> </product> product/widget.html [% p = ../data/widget.xml %] [% p.price %] With the URI fragment syntax, you'll be able to get at things direct: [% ../data/widget.xml#price %] Cheers A _______________________________________________ templates mailing list [email protected] http://lists.template-toolkit.org/mailman/listinfo/templates
