Jon Stevens :

> Maybe it would be a good idea to allow #macro's to be passed in a value if
> they have a #end. Therefore, it would be easy to do something like this:
>
> context.put("escape", new Escape());
>
> -----------
> #macro (htmlescape $pass)
> $escape.getText($pass)
> #end
> -----------
>
> Then in your page:

> #htmlescape
> <>""
> #end

You mean all the stuff between '#htmlescape' and '#end' is passed as an arg
to the VM #htmlescape?

Hm.  Well, that's certainly a unique approach.

I think that's confusing, though.  We have a clean directive syntax of
#<directive>( [args] ) and this not only breaks it, but jumps up and down on
it until it cries 'Uncle!'.

I wonder if we could do something cleaner, like a directive like :

  #blockassign( $foo )
    <VTL>
  #end

where after this, $foo == the VTL in the block or alter #literal to take an
optional arg such that

#literal()
  <VTL>
#end

renders to the output the literal bock

and

#literal( $foo )
  <VTL>
#end

does the $foo = the VTL thing above.

and then you can toss into a VM for immediate rendering like :

  #htmlescape($foo)

or somthing more advanced, like :

  #set($schlorf = "#htmlescape( $foo )" )


> It would make it really easy to emulate #defines that way and seems to be
a
> cleaner way of implementing things than making everyone create their own
> #directives like WM does. :-)

> I would be +1 to have it be severely restricted though. For example, you
can
> only pass in one argument and that argument can only be a String.

I would prefer a mechanism like #blockassign() or #literal($foo) before we
break our beautiful syntax :)


-jon

--
Honk if you love peace and quiet.

Reply via email to