Re: Simple list of all methods, properties, variables available to templates?
ANS Developer Team <[email protected]>
| Newsgroups | gmane.comp.jakarta.velocity.user |
|---|---|
| Message-ID | <CABXqMd3XzzqXHcpRvf_4eKTd2S9cPWie-SsJKj=0_snV_taiTA@mail.gmail.com> |
Thanks Nathan, just got a chance to test this. $context.put("context",
context) is just being written verbatim, rather than being evaluated.
I've stuck into several different locations (templates, structures,
content), some of which I know have Velocity processing enabled.
Since it's not being evaluated, does this mean the context doesn't have a
reference to itself in my CMS?
Tried $class.inspect($context.get($key)), but same result.
On Wed, Feb 13, 2013 at 11:08 AM, Nathan Bubna <[email protected]> wrote:
> Yes, if the context has a reference to itself: context.put("context",
> context);
> Then you can #foreach( $key in $context.keySet() ) $key =
> $context.get($key)#end
> And if you add something like the ClassTool from the VelocityTools
> project, then you can avoid the nastiness of trying to use the
> reflection API within a template and explore what
> $class.inspect($context.get($key)) gives you.
>
>
> http://velocity.apache.org/tools/devel/javadoc/org/apache/velocity/tools/generic/ClassTool.html
>
> But again, you need to have access to the VelocityContext being used
> to merge the templates. I don't know if your CMS is using
> VelocityTools, but all of this gets much easier if it is using Tools
> 2. There's even a ContextTool:
>
> http://velocity.apache.org/tools/devel/javadoc/org/apache/velocity/tools/generic/ContextTool.html
>
> On Tue, Feb 12, 2013 at 8:10 PM, ANS Developer Team <[email protected]>
> wrote:
> > Thanks, is it possible to do that from within a Velocity template?
> >
> >
> > On Tue, Feb 12, 2013 at 2:09 PM, Sergiu Dumitriu
> > <[email protected]>wrote:
> >
> >> On 02/12/2013 12:17 PM, ANS Developer Team wrote:
> >> > Ah thanks, it's pretty sparse, hence why I'm asking here. Much
> >> > appreciated, will figure it out from source.
> >>
> >> If you can get your hands on the current VelocityContext, then you could
> >> list all the properties it contains (it extends Map).
> >>
> >> >
> >> > On Tue, Feb 12, 2013 at 12:42 AM, Nathan Bubna <[email protected]>
> wrote:
> >> >
> >> >> Velocity doesn't provide anything but the syntax. You will have to
> >> >> seek documentation from Vosao CMS.
> >> >>
> >> >> On Mon, Feb 11, 2013 at 6:57 PM, ANS Developer Team <[email protected]>
> >> >> wrote:
> >> >>> Hi all, I'm trying to find a list all of the above that can be used
> in
> >> a
> >> >>> template, preferably with a brief description of what it does (but
> >> that's
> >> >>> not entirely necessary).
> >> >>>
> >> >>> I'm building site using the Velocity-based Vosao CMS, and have no
> idea
> >> >> what
> >> >>> what methods, properties, and variables are available to me except
> the
> >> >>> sparse few used in the example Blog app.
> >> >>>
> >> >>> For example there's a $page.friendlyURL property, but what other
> >> >> properties
> >> >>> does $page have? Having trouble finding this information.
> >> >>>
> >> >>> I've found the Velocity VTL Reference Guide, but that's more of a
> >> syntax
> >> >>> uide without a comprehensive list, and I've found the online
> Velocity
> >> API
> >> >>> docs, but that's overkill and I still can't find the $page object
> in it
> >> >>> (not sure what class it's in).
> >> >>>
> >> >>> Any help on this much appreciated!
> >>
> >>
> >> ---------------------------------------------------------------------
> >> 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]
>
>