Hi Zazo,

In freemarker  "[#assign inlineTemplate = templateSource?interpret]"  returns a 
executable template, which is rendered when you include it with @inlineTemplate.

You're trying to capture the rendered text, but that is not the same as the 
template object created by ?interpret.

You can't do things the way you are trying. ?interpret won't help you.

A solution could be to do the rendering inside your model. So your code could 
look something like this:

[code]
[#list content?children as subnode]
  [#assign templateSource = model.myclass(subnode.text!)]
  ${model.myclass(templateSource)}
 [/#list]
[/code]

And then in the model:

public String myclass(String templateSource){
        Reader reader = new StringReader(templateSource);
        Writer out = new StringWriter();
        FreemarkerHelper.getInstance().render(reader, new HashMap<String, 
Object>(), out);
        String result = minify(out.toString());
        return result;
}


Something like that.
This is approximately how we are solving the "minification" problem.

Regards from Vienna,

Richard




-----Ursprüngliche Nachricht-----
Von: [email protected] [mailto:[email protected]] 
Im Auftrag von Zozo (via Magnolia Forums)
Gesendet: Donnerstag, 20. Dezember 2012 19:59
An: Magnolia User List
Betreff: [magnolia-user] Executing a class over interpreted/rendered FTL code

Hi,

I would like to execute some specific codes over a Freemarker template.

[b]These works fine:[/b]
[code][#list content?children as subnode]
  [#assign templateSource = model.myclass(subnode.text!)]
  [#assign inlineTemplate = templateSource?interpret]
  [@inlineTemplate /]
[/#list][/code]

The problem here is that I need to have the underneath template interpreted 
befaore sending it to "myclass".

[b]These DOES NOT work:[/b]
[code][#list content?children as subnode]
  [#assign templateSource = subnode.text!]
  [#assign templateSource2 = templateSource?interpret]
  [#assign inlineTemplate = model.myclass(templateSource2)]
  [@inlineTemplate /]
[/#list][/code]

FYI, "myclass" is used to minify some child Javascripts. So because the 
sub-templates contains some Freemarker code, the minification does not work.

>From 
>[url=http://forum.magnolia-cms.com/forum/thread.html?threadId=4e5c8833-44cc-4e72-aea0-3b16afbadbe4#1bdf5998-fd22-4c79-b404-efe4f6d30b87]this
> post[/url], someone proposed this code:
[code][#list content?children as subnode]
  ${model.minify(subnode.text?interpret!"")}
[/#list][/code]
It DOES NOT work neither.

Any solutions?

Thanks

-- 
Context is everything: 
http://forum.magnolia-cms.com/forum/thread.html?threadId=ba7ebf9c-f61a-49cb-9a7b-e38b7c2e8747


----------------------------------------------------------------
For list details, see http://www.magnolia-cms.com/community/mailing-lists.html
Alternatively, use our forums: http://forum.magnolia-cms.com/
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------





----------------------------------------------------------------
For list details, see http://www.magnolia-cms.com/community/mailing-lists.html
Alternatively, use our forums: http://forum.magnolia-cms.com/
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------

Reply via email to