This article covers a Bloomreach Experience Manager version 11. There's an updated version available that covers our most recent release.

Freemarker Snippets

List all properties of a bean

To list all properties of the document bean with their values:

<ul>
  <#list document.properties?keys as prop>
    <li>${prop} = ${document.getProperty(prop)}</li>
  </#list>
</ul>

Render an image

This snippet will cause HST to create a link to the "original variant" of an image. Make sure you have HST's tag library included.

<!#-- Make sure you have the hst TabLib assigned -->
<#assign hst=JspTaglibs["http://www.hippoecm.org/jsp/hst/core"] >

<!#-- Create URL that points to the document.image.original bean -->
<@hst.link var="img" hippobean=document.image.original />

<!#-- Render the image -->
<img src="${img}"/>

Render an HTML field

The contentRewriter causes all internal links and images embedded in the HTML content (the body field in this example) to be converted to valid URLs:

<@hst.html contentRewriter=contentRewriter hippohtml=document.body/>

Including other Freemarker templates

Include a template from the classpath:

<#include "/WEB-INF/lib/htmlTags.ftl">

Include a template from the repository (in a template that is loaded from the repository):

<#-- Include a sibling -->
<#include "myinclude.ftl">

<#-- Include from a path relative to the current template location -->
<#include "../../common/hst:templates/myinclude.ftl">

Setting the appropriate Locale

Derive the Locale from the used HST mount as follows:

<#setting locale=hstRequest.requestContext.resolvedMount.mount.locale>
Did you find this page helpful?
How could this documentation serve you better?
On this page
    Did you find this page helpful?
    How could this documentation serve you better?