Thanks, good pointers! IncludeNotFound looks like it'd do the trick, but for every #parse, not just the one I want to make conditional.

Why is it that $engine.resourceExists($template) throws an exception rather than returning false?

        Erik



On Dec 29, 2008, at 3:22 PM, Nathan Bubna wrote:

There's no canonical way of doing this within a template yet, but
there is the IncludeEventHandler which was added in Velocity 1.5.
There is even an IncludeNotFound implementation provided.  You may be
able to set up a simpler, exception free solution using those.
Alternately, you could pretty easily create a VelocityTool that did
this.

On Mon, Dec 29, 2008 at 4:10 AM, Erik Hatcher
<[email protected]> wrote:
Hi,

I'd like to have some construct like this in a template:

#if(templateExists($template))
  #parse($template)
#end

Is there a canonical/approved way of doing this?   I've put the
VelocityEngine into the context and tried:

#if($engine.resourceExists($template))
  ...
#end

But that still throws an exception when $template does not exist. I want to avoid the exception and simply skip #parse'ing if a template does not exist

Thanks,
      Erik


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to