Class LinkHandlebarsHelper
- java.lang.Object
-
- com.terminalfour.publish.handlebars.helper.BaseHelper
-
- com.terminalfour.publish.handlebars.helper.content.element.LinkHandlebarsHelper
-
- All Implemented Interfaces:
com.github.jknack.handlebars.Helper<Object>
@Component public class LinkHandlebarsHelper extends BaseHelper
The {{{link ...}}} handlebars helper can be used to publish Section and Content Link Content Elements.Usage
It can be used as either a standard handlebars expression or a block level expression, with the latter providing the web developer with more control over the published link.
Attributes
The expression itself is quite simple, taking only a single attribute.
- element - The Content Element to be published.
Examples
Standard expression
<p>{{{link element="Link Content Element"}}}</p>
In the above example a standard link is generated and returned. It should be noted that as the handlebars expression is expected to return HTML, it should be triple-stashed.
Block expression
{{#link element="Link Content Element"}} <p><a href="{{linkUrl}}" title="{{publish element="Name"}}">{{linkText}}</a></p> {{/link}}
As can be seen in the code snippet above, the standard link is modified by adding the Name of the Content Item as the title attribute within the generated link.
When used as a block-level element, the {{linkUrl}} and {{linkText}} handlebars expressions are available for use, giving the web developer much more control over the generated HTML.
-
-
Constructor Summary
Constructors Constructor Description LinkHandlebarsHelper(IElementAPI elementApi, IJsonAPI jsonApi)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
apply(Object context, com.github.jknack.handlebars.Options options)
Theapply
method is the main entry point for handlebars.java helpers.
-
-
-
Constructor Detail
-
LinkHandlebarsHelper
@Autowired public LinkHandlebarsHelper(IElementAPI elementApi, IJsonAPI jsonApi)
-
-
Method Detail
-
apply
public Object apply(Object context, com.github.jknack.handlebars.Options options) throws IOException
Description copied from class:BaseHelper
Theapply
method is the main entry point for handlebars.java helpers.It is called internally by the handlebars.java engine when a matching handlebars.java expression is encountered.
- Specified by:
apply
in interfacecom.github.jknack.handlebars.Helper<Object>
- Specified by:
apply
in classBaseHelper
- Parameters:
context
- The currently executing context.options
- The options.- Returns:
- The generated output.
- Throws:
IOException
- If processing of the expressions fails.
-
-