[stringtemplate-interest] template existence testing

Zenaan Harkness zen at freedbms.net
Sat Mar 29 06:01:43 PDT 2008


On Sat, Mar 29, 2008 at 11:43:30PM +1100, Zenaan Harkness wrote:
> It might sound odd, but I would like to be able to, within an <if(...)>
> block, test for the existence of a specific template name.

I've been thinking about the performance of such a feature.

Each time such a test is made (if it existed), the "polymorphic" lookup
would occur, starting at the lowest template group, and this would
happen for each method body (those which could be specialized) of each
attribute being rendered, for each output view being rendered (eg, there
might be a bean, a struct, and more).

For a large model, this would be lots of unnecessary redundancy
multiplying into a lot of run time.

My runs are offline, so that would be OK for me, but nevertheless, a
more efficient mechanism might be useful, such as pre-scanning all the
template names when loaded by my template driver, and doing a
pre-rendering model/attribute cross-reference, and applying an
appropriate boolean switch for each custom template.
This process can be hidden in the template driver, so normal user code,
and the templates themselves, can forget it even exists.

I'll hack this for now...

-- 
Homepage: www.SoulSound.net -- Free Australia: www.UPMART.org
Please respect the confidentiality of this email as sensibly warranted.


More information about the stringtemplate-interest mailing list