mail seamons.com wrote:
> I have included a test program that tests what I am
requesting. I would like
> to see the status of reserved words become a little
less reserved. There is
> a lot of intuition that can be gathered based upon the
place you are in.
Yep, that's all part of TT3. You can't do it (easily, if at
all) in TT2
because we tokenise everything up front. We see GET and
mark it as a
keyword, and use that the drive the grammar forward (using
YAPP).
In TT3 the parse is recursive descent and knows where to
look for a keyword
and where it can safely look for a variable that might
otherwise look
like a keyword.
Same goes for operators. You should be able to have
variables called
'and' and 'or' if you really want to confuse people.
[% IF IF and and or or %]
=> <key:IF> <var:IF> <op:and>
<var:and> <op:or> <var:or>
...
[% ELSIF ELSIF or or and and %] =>
=> <key:ELSIF> <var:ELSIF>
<op:or> <var:or> <op:and> <var:and>
Obfuscated TT3 anyone?
Rewriting the parser was always the big part of TT3. Apart
from some
of the code generation and handling some of the more complex
directives,
it's more-or-less done. Certainly most of the low-level
stuff like
parsing TT statements.
One particularly shiny thing in TT3 is that you can use
explicit namespaces
to disambiguate the language elements if necessary.
For example, where you currently write:
[% INCLUDE $filename %]
the leading '$' in filename tells the parser that a variable
name follows
rather than the unquoted filename it usually expects. In
TT3 you'll also
be able to say:
[% INCLUDE var:filename %]
And if you want a template, file, image or some other kind
of thingy where
you would normally get a variable, you can write:
[% t = template:header %] # [% t.modtime %], [%
t.metadata %], etc.
[% f = file:blah.txt %] # [% f.modtime %], [% f.owner
%], etc.
[% i = image:foo.gif %] # [% i.width %], [% i.height
%]
[% x = xml:example.xml %] # [%
x.dom.getElementsByTagName('h1') %]
All depending on what providers you've bound to your various
namespaces,
of course. In essence, all TT variables and other
identifiers will be
addressable via URIs which makes things nicely, er, uniform.
Cheers
A
_______________________________________________
templates mailing list
templates template-toolkit.org
http://lists.template-toolkit.org/mailman/listinfo/t
emplates
|