Re: Can I get the name of the template from inside the template?
Christopher Schultz <[email protected]> Wed, 3 May 2023 19:33:18 -0400
| Newsgroups | gmane.comp.jakarta.velocity.user |
|---|---|
| Message-ID | <[email protected]> |
Mike, What about calling #parse and other (?) types of includes? Same thing with m= acros which call other macros etc. Velocity must already know what=E2=80=99s= going on. Can=E2=80=99t the template get access to that? -chris > On May 3, 2023, at 17:30, Mike Kienenberger <[email protected]> wrote: >=20 > =EF=BB=BFRather than trying to get the internal name, you'd probably be be= tter off > injecting the name yourself. You normally have access to the name of the > template around the same time that you set up the context. >=20 >=20 >> On Wed, May 3, 2023 at 11:42=E2=80=AFAM Christopher Schultz < >> [email protected]> wrote: >>=20 >> All, >>=20 >> 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. >>=20 >> 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. >>=20 >> Is there a "standard" way to do this? >>=20 >> 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. >>=20 >> Thanks, >> -chris >>=20 >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [email protected] >> For additional commands, e-mail: [email protected] >>=20 >>=20