You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by Niall Loughnane <ni...@yahoo.com> on 2011/11/29 14:59:30 UTC

Imbed Other Velocity Templates within a velocity template

Hi,



Is there a way in Velocity Templates to imbed other velocity templates?



I have the following velocity template "mypage_html.vm",
"
<html>
    <body>
         text to be displayed

    </body>

</html>

"



For reusability purposes I want to have 2 base velocity templates:

"mypage_html_header.vm":
"
<html>

    <body>
"

"mypage_html_footer.vm":

"
    </body>


</html>
"



Then to refactor "mypage_html.vm" to:
"
#include mypage_html_header.vm
         text to be displayed


#include mypage_html_footer.vm

"



Is this possible in Velocity Templates?



Thanks in Advance,

Niall

Re: Imbed Other Velocity Templates within a velocity template

Posted by Sergiu Dumitriu <se...@xwiki.com>.
On 11/29/2011 08:59 AM, Niall Loughnane wrote:
> Hi,
>
>
>
> Is there a way in Velocity Templates to imbed other velocity templates?
>
>
>
> I have the following velocity template "mypage_html.vm",
> "
> <html>
>      <body>
>           text to be displayed
>
>      </body>
>
> </html>
>
> "
>
>
>
> For reusability purposes I want to have 2 base velocity templates:
>
> "mypage_html_header.vm":
> "
> <html>
>
>      <body>
> "
>
> "mypage_html_footer.vm":
>
> "
>      </body>
>
>
> </html>
> "
>
>
>
> Then to refactor "mypage_html.vm" to:
> "
> #include mypage_html_header.vm
>           text to be displayed
>
>
> #include mypage_html_footer.vm
>
> "
>
>
>
> Is this possible in Velocity Templates?
>

Yes, see 
http://velocity.apache.org/engine/releases/velocity-1.7/vtl-reference-guide.html#aparse_-_Renders_a_local_template_that_is_parsed_by_Velocity

#parse('mypage_html_header.vm')
text to be displayed
#parse('mypage_html_footer.vm')

-- 
Sergiu Dumitriu
http://purl.org/net/sergiu/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org