Can I get the name of the template from inside the template?
Christopher Schultz <[email protected]> Wed, 3 May 2023 11:41:58 -0400
| Newsgroups | gmane.comp.jakarta.velocity.user |
|---|---|
| Message-ID | <[email protected]> |
All, I'd like too be able to get access to the name of the template currently being rendered. It looks like that information should be in the VelocityContext being used, but I'm having trouble getting a reference to that. This is in a webapp situation, and I'm using velocity-tools so I tried the ContextTool which will give me a ChainedContext which implements the Context interface but I'm not sure where to go from there. For example, I don't see a way to walk my way up the chain to the most-parent-context, or really anything that would give me access to e.g. getCurrentTemplateName. Is there a "standard" way to do this? I'm using Velocity 1.7 at this point (yeah, I know). I'm perfectly happy to hack it a little bit and I already have a custom VelocityLayoutServlet with a custom mergeTemplate method, so ther is an opportunity there to inject some instrumentation. Thanks, -chris