[Templates] INCLUDE context / NAMESPACE

Andrew McFarland amcfarl@unite.net
Thu, 14 Nov 2002 08:42:23 +0000


At 17:45 13/11/2002 +0000, "Paul Tomlin" <paul@digitlondon.com> wrote:
<snip>
 >Any ideas? I'm sure that there is probably a way to achieve
 >what I want but it may not be in the way I am expecting.
<snip>

I think a lot of what you want can be achieved outside of TT.

Don't use the style attribute in production code - it causes all sorts of 
weird problems[0]. Use an external CSS[1] file and the class attribute. 
Then use rules in the CSS like this:

p.styled {color: red}

div.styled {color: blue}

Using more complex CSS rules, and a properly structured (X)HTML document, 
you can probably get all the styling you need[2]. In fact if you do it 
really properly you may even be able to avoid the class attribute 
altogether.

If you really want to do it in TT, something like

$context = {
    bat => "cool"
};

[% PROCESS foo bar=bat %]

[% BLOCK foo%]
<div class="[% context.${bar} %]">
[% END %]

may be what you want, but I'll let TT experts comment on that one.

[0] See http://aamcf.co.uk/temp/botch in Netscape 4 with CSS on for an 
extreme example.
[1] Assuming you are using CSS
[2] E-mail me offlist for tips if you need to. Its way OT for here :)
--
Andrew McFarland
UNITE Solutions          Phone 028 9077 7338
http://www.unite.net/    Fax   028 9077 7313