Quantcast

How to get the list of ftl files and their macros used to render the current ftl

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to get the list of ftl files and their macros used to render the current ftl

Albert Kam
For example, in my current ftl, albert.ftl, is making use of several other ftls, like :
layout.ftl, util.ftl, and other ftls that are imported but not necessarily used.

Both layout.ftl and util.ftl also have many utility macros, and for albert.ftl, i'm just using several like <@layout.layout>, or <@layout.announcement>, or <@util.mybutton>, etc.

Is there any way that in my albert.ftl,  i can 'print out' the content of the ftl macros that are actually used ? And whether i can get the full filepath to the ftl, so i can save the changes i make.

I'm hoping to achieve easy 'view and edit ftl source' to help me with applying i18n on uni18n-ed texts, and to quick fix mistakes in the production environment without having to ssh+vim on the server.

Regards from Jakarta,
Albert Kam

--
Do not pursue the past. Do not lose yourself in the future.
The past no longer is. The future has not yet come.
Looking deeply at life as it is in the very here and now,
the practitioner dwells in stability and freedom.
(Thich Nhat Hanh)

------------------------------------------------------------------------------
Put Bad Developers to Shame
Dominate Development with Jenkins Continuous Integration
Continuously Automate Build, Test & Deployment
Start a new project now. Try Jenkins in the cloud.
http://p.sf.net/sfu/13600_Cloudbees
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to get the list of ftl files and their macros used to render the current ftl

Daniel Dekany
Saturday, April 12, 2014, 4:06:42 AM, Albert Kam wrote:

> For example, in my current ftl, albert.ftl, is making use of several other ftls, like :
> layout.ftl, util.ftl, and other ftls that are imported but not necessarily used.
>
> Both layout.ftl and util.ftl also have many utility macros, and for
> albert.ftl, i'm just using several like <@layout.layout>, or
> <@layout.announcement>, or <@util.mybutton>, etc.
>
> Is there any way that in my albert.ftl,  i can 'print out' the
> content of the ftl macros that are actually used ?

There's nothing built in for that. You could walk the AST starting
with getRootTreeNode(), but it's a non-published API and as such can
change over time. Although the output of
TemplateElement.getCanonicalForm() is probably stable enough.

> And whether i can get the full filepath to the ftl, so i can save
> the changes i make.

Directly from the Template, you can't. It only remembers the path-like
template name, not the original source (which is not always a file).
OTOH if you have knowledge about where the templates are loaded from
(i.e., from the TemplateLoader setup), you can possibly deduce the
real path from the Template.getName().

BTW, associating the source of the template with the Template object
is on my TODO, but things go slowly nowadays...

> I'm hoping to achieve easy 'view and edit ftl source' to help me
> with applying i18n on uni18n-ed texts, and to quick fix mistakes in
> the production environment without having to ssh+vim on the server.
>
> Regards from Jakarta,
> Albert Kam
>

--
Thanks,
 Daniel Dekany


------------------------------------------------------------------------------
Put Bad Developers to Shame
Dominate Development with Jenkins Continuous Integration
Continuously Automate Build, Test & Deployment
Start a new project now. Try Jenkins in the cloud.
http://p.sf.net/sfu/13600_Cloudbees
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
Loading...