Includes in Velocity Templates

Brent Putman putmanb at georgetown.edu
Thu Jul 7 20:59:36 EDT 2016



On 7/7/16 7:20 PM, Klingenstein, Nate wrote:
>
> We’re looking to include a common footer on multiple pages that is a
> fairly hefty chunk of HTML in e.g. login.vm and error.vm.
>
>  
>
> Embedded HTML tags in the Spring properties in /messages will render,
> but I don’t know if limitations exist in length or formatting or
> whether there are other practical issues to be encountered.
>

I don't know about length limitations either.... But aside from that,
considering the task of just maintaining stuff over time, if it's a ton
of text, multiple paragraphs, images, etc, putting that into various
message properties probably isn't the nicest way to go.

>  
>
> Is that the best approach?  Any deployers with enough experience here
> to recommend better, if not best, practices?
>


The Velocity Template Language (VTL) has its own concept of includes,
both unparsed (#include) [1] and parsed (#parse) [2].  So that's
probably the way to go for large amounts of content.

As far as the naming and referencing of the included template(s), you
should be able to put a foo.vm in the directory defined by the property
idp.views (which defaults to idp.home/views), and then reference it in
login.vm etc simply unqualified, like "#parse ( "foo.vm" )".



[1]
http://velocity.apache.org/engine/1.7/vtl-reference.html#include-renders-local-files-that-are-not-parsed-by-velocity

[2]
http://velocity.apache.org/engine/1.7/vtl-reference.html#parse-renders-a-local-template-that-is-parsed-by-velocity

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://shibboleth.net/pipermail/users/attachments/20160707/c9da149c/attachment-0001.html>


More information about the users mailing list