Includes in Velocity Templates

Klingenstein, Nate nklingenstein at calstate.edu
Thu Jul 7 21:13:43 EDT 2016


This is great, thanks. If I can try summarizing, for "relatively" short snippets of anything, HTML included, using Spring properties will usually be the better choice.

For larger stanzas or ones that require dynamism, a dedicated .vm included via the proper choice of include/parse is better.  Nice that reference is that easy.

Ultimately, many cases come down to preference, and this also offers nice ways to delegate or split management of pages and text.

Semt frim mt iPone

On Jul 7, 2016, at 17:59, Brent Putman <putmanb at georgetown.edu<mailto:putmanb at georgetown.edu>> wrote:



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

--
To unsubscribe from this list send an email to users-unsubscribe at shibboleth.net<mailto:users-unsubscribe at shibboleth.net>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://shibboleth.net/pipermail/users/attachments/20160708/65c297f6/attachment.html>


More information about the users mailing list