Will -
Thanks for the nudge...
> (1) Write a custom directive #IfBoolean
I wouldn't want a new directive. One of my unstated requirements was
that the templates would continue to work with a standard velocity
engine. Good idea, but I apologize for that omission. :-)
Another unstated goal was to explicitly disallow expressions inside the
#if() so that the templates would heavily limit designers (and me) from
inadvertantly droping in logic.
#if ($temp < 32) FREEZING #end
versus
#if ($temp.isBelowFreezing()) FREEZING #end
The presentation might make FREEZING things bold and blue, but I prefer
that the presentation layer does NOT define what FREEZING means. In my
apps, I want that in a biz rule, and besides it likely varies - for
example if the $temp is in Celsius or Fahrenheit, FREEZING is a
different thing.
> (2) Alter the Velocity source code. User javacc to compile a revised
Parser.jjt.
I'll have to read up a bit more on how javacc works, do you have a good
reference link?
> Since your syntax currently works in Velocity
> (you want to limit what's acceptable, not add new syntax),
Sorry, I'm a little confused. Does this mean that Parser.jjt (which I
assume is a Javacc definition/config file) would -not- need to be
altered?
BTW - I don't want to break existing parsing functionality... I'd like
to turn this strictness on/off with a switch on a per-template basis.
(kinda like in Perl where you can specify a "use Strict;" on a script
and then the perl interpreter will puke if you do nasty things... but
you can turn off the flag so that included modules that aren't as picky
can still run.)
> I don't think you'd have to do
> anything else. (correction: you'd need to change
> ASTIfStatement.java to throw an exception for non-boolean references).
Okay, I'll have a look at that.
> This would be the section to revise in Parser.jjt. You'd
> need to change
> "Expression()" to only allow a reference or a method call.
>
> void IfStatement() : {}
> {
> <IF_DIRECTIVE> [<WHITESPACE>] <LPAREN> Expression() <RPAREN>
> ( Statement() )+ #Block
> [ LOOKAHEAD(1) ( ElseIfStatement() )+ ]
> [ LOOKAHEAD(1) ElseStatement() ]
> <END>
> }
While I was looking at ASTIfStatement, the first comment says:
* Please look at the Parser.jjt file which is
* what controls the generation of this class.
Hmmm... so if I patch that file, will another process of the build
over-write my changes?
Thanks for the help!
Timo
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]