Quantcast

templating with no file based system (OSGI question)

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

templating with no file based system (OSGI question)

halil
Hi All,

I am developing a web application based on OSGI. I have templates on different bundles and want to produce a html code by merging differnt ftl files which are on different bundles. I need this scenario because I need versioned templates...

I am expecting to find JAVA API Documentation but could not find. I want to implement programmatically which is done as below with Freemarker template language.

<#macro myLayout>
  <html>
    <body style="width:100%;height:100%">
      <table border="1" cellspacing="0" cellpadding="0" style="width:100%;height:100%">
        <tr>
          <td colspan="2">
            <#include "header.ftl"/>
          </td>
        </tr>
        <tr>
          <td>
            <#include "menu.ftl"/>
          </td>
          <td>
            <#nested/>
          </td>
        </tr>
        <tr>
          <td colspan="2">
            <#include "footer.ftl"/>
          </td>
        </tr>
      </table>
    </body>
  </html>
</#macro>


I need such hypothetical java api which does above templating.

Freemarker.macro("mylayout.ftl")
.include(1,"header.ftl")
.include(2,"menu.ftl")
.include(3,"footer.ftl")
.process(FileUtils.read("nested.ftl"));


I see that Freemarker include directive refers to the files, meanly it is file system based. I could not find a documentation which helps me do it programmatically as above...

I am on a wrong way? or I missed something in the understanding of Freemarker architecture? I don't know...

Could you please help me on this issue?

thanks in advance,


-halil.


------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
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: templating with no file based system (OSGI question)

Daniel Dekany
FreeMarker template loading is not file system based. See
Configuration.setTemplateLoader(...), or the convenience methods like
setClassLoaderForTemplateLoading. So as far as OSGi allows the
FreeMarker classes to access the classes of the other bundle (which
contains the templates), a ClassTemplateLoader should do the trick.


Wednesday, May 20, 2015, 4:15:16 PM, halil wrote:

> Hi All,
>
> I am developing a web application based on OSGI. I have templates
> on different bundles and want to produce a html code by merging
> differnt ftl files which are on different bundles. I need this
> scenario because I need versioned templates...
>
> I am expecting to find JAVA API Documentation but could not find. I
> want to implement programmatically which is done as below with Freemarker template language.
>
> <#macro myLayout>
>   <html>
>     <body style="width:100%;height:100%">
>       <table border="1" cellspacing="0" cellpadding="0" style="width:100%;height:100%">
>         <tr>
>           <td colspan="2">
>             <#include "header.ftl"/>
>           </td>
>         </tr>
>         <tr>
>           <td>
>             <#include "menu.ftl"/>
>           </td>
>           <td>
>             <#nested/>
>           </td>
>         </tr>
>         <tr>
>           <td colspan="2">
>             <#include "footer.ftl"/>
>           </td>
>         </tr>
>       </table>
>     </body>
>   </html>
> </#macro>
>
>
> I need such hypothetical java api which does above templating.
>
> Freemarker.macro("mylayout.ftl")
> .include(1,"header.ftl")
> .include(2,"menu.ftl")
> .include(3,"footer.ftl")
> .process(FileUtils.read("nested.ftl"));
>
>
> I see that Freemarker include directive refers to the files, meanly
> it is file system based. I could not find a documentation which
> helps me do it programmatically as above...
>
> I am on a wrong way? or I missed something in the understanding of
> Freemarker architecture? I don't know...
>
> Could you please help me on this issue?
>
> thanks in advance,
>
>
> -halil.
>

--
Thanks,
 Daniel Dekany


------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
Loading...