Re: Can I get the name of the template from inside the template?

Mike Kienenberger <[email protected]> Wed, 3 May 2023 17:29:43 -0400
Newsgroups gmane.comp.jakarta.velocity.user
Message-ID <CAM1yOjZoUu9vYHuJVee9PbPPsE7M14BYh+WxpW5gt0n429nB2w@mail.gmail.com>
--00000000000007f7de05fad0c2bb
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Rather than trying to get the internal name, you'd probably be better 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.


On Wed, May 3, 2023 at 11:42=E2=80=AFAM Christopher Schultz <
[email protected]> wrote:

> 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
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

--00000000000007f7de05fad0c2bb--