1. I have a class with a static method like this:
int result = Dice.roll("2d6+1") ;
which rolls two six sided dice adds one, and returns the result.
I'd like to make this facility available from a template. I
can do this like so:
$dice.roll("2d6+1")
However, this is quite verbose. So, I customized a context
to understand this:
$roll2d6
which is better, but now I can't do the plus stuff, because
it is not a legal template identifier. What I would most
like to implement is this:
$roll("2d6+1") or, even better:
$2d6+1 or
$"2d6+1" or something like that
So is there any way to do that with a custom context?
2. The more I use Velocity, the more I am convinced that
template errors should be returned as the template contents,
in addition to being put in the log file. (This behavior could
be changed via a configuration item.) Right now, minor typos
require you to look at the velocity.log, and if you forget to
do that, they are just mysterius. (Obviously, people who use
Velocity a lot will not need this, but first timers and occational
users, which are most users, will be burned by this.)
3. Right now I have an object (foo) with two initializers
(init1 and init2). I would like the initialization call to be
part of the template so the user can choose which to use:
$foo.init2()
got a bar: $foo.bar
My problem with this is that I get an extra black line at the
top of the form when I do it. Is there a #ignore feature? So
I could do a:
#ignore($foo.init2())
got a bar: $foo.bar
or something like that? I tried #set(ignore=$foo.init2()), but
it didn't work. I think because the init2 method returned void.
Any thoughts how how best to do this? I suppose I could do this:
$foo.init2()got a bar: $foo.bar
but it looks ugly, and I suspect I'll have whitespace problems,
anyway.
Joshua Levy
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/