Re: Extensions to allow introspection of Freemarker template

David Levine <[email protected]> Thu, 29 May 2014 13:10:16 -0700
Newsgroups gmane.comp.web.freemarker.devel
Message-ID <CADqkULF7FrGzXys-6hZOyfdnpdQ1SL7jWua+3JvCi_YYXz8gnQ@mail.gmail.com>
Hello Christopher,

Do you want to parse the freemarker HTML to pull out the freemarker
variable references so you can create a data model that will work for any
given freemarker template?  I can see why you'd want to do that.  You need
want to live with some restrictions in terms of what you might pick up
automatically by introspection.

In our case, what we do is define the data model separately in an XML file,
such that the data model matches what the form expects.  From that data
model, we generate a form that a user can fill out, and from that form
input we generate the data model which will match what the HTML expects (in
terms of Freemarker variable references).

Hope that helps!

David


On Tue, May 27, 2014 at 6:58 AM, Wong, Christopher <[email protected]>
wrote:

>  I work with user-submitted templates, and would like Freemarker support
> some form of introspection of a template. For example, I might want to know
> what identifiers the template will request from the model. Freemarker
> already has something very close to this: the public method
> Template.getRootTreeNode exposes a DOM-like structure the end user.
> Unfortunately, the TemplateElement classes that comes back are mostly not
> visible to the public.
>
>
>
> Since I'd rather not fork an internal copy of Freemarker, I'd like to
> explore the possibility of contributing changes to the Freemarker project
> to enable template introspection. I want to see if there's an approach that
> the maintainers will find acceptable.
>
>
>
> 1) The easiest way to accomplish this is to make the TemplateElement
> hierarchy public and add public getters to these classes. On the other
> hand, this might expose more than you'd like. 2) You have implemented
> similar functionality by having this class implement the TreeNode interface
> to expose this tree as a Swing component. Perhaps a separate interface
> hierarchy will provide acceptable decoupling?
>
> ------------------------------
> This e-mail and files transmitted with it are confidential, and are
> intended solely for the use of the individual or entity to whom this e-mail
> is addressed. If you are not the intended recipient, or the employee or
> agent responsible to deliver it to the intended recipient, you are hereby
> notified that any dissemination, distribution or copying of this
> communication is strictly prohibited. If you are not one of the named
> recipient(s) or otherwise have reason to believe that you received this
> message in error, please immediately notify sender by e-mail, and destroy
> the original message. Thank You.
>
>
> ------------------------------------------------------------------------------
> The best possible search technologies are now affordable for all companies.
> Download your FREE open source Enterprise Search Engine today!
> Our experts will assist you in its installation for $59/mo, no commitment.
> Test it for FREE on our Cloud platform anytime!
>
> http://pubads.g.doubleclick.net/gampad/clk?id=145328191&iu=/4140/ostg.clktrk
> _______________________________________________
> FreeMarker-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/freemarker-devel
>
>

------------------------------------------------------------------------------
Time is money. Stop wasting it! Get your web API in 5 minutes.
www.restlet.com/download
http://p.sf.net/sfu/restlet

_______________________________________________
FreeMarker-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel