Class PublishHandlebarsHelper
- java.lang.Object
-
- com.terminalfour.publish.handlebars.helper.BaseHelper
-
- com.terminalfour.publish.handlebars.helper.content.element.PublishHandlebarsHelper
-
- All Implemented Interfaces:
com.github.jknack.handlebars.Helper<Object>
@Component public class PublishHandlebarsHelper extends BaseHelper
The {{publish ...}} handlebars helper is used to "publish" a Content Element.It should be noted that in many cases this helper outputs HTML code, so it should be surrounded with a triple-stash instead of the standard double-stash}}, when required.
Content Elements that would be expected to contain T4 Tags in their output have those tags processed directly by this helper. These element types are HTML, Media and Section/Content Links.
Usage
Attributes
The expression itself is quite simple, taking only a single attribute.
- element - The Content Element to be published
Standard expression
{{publish element="Content Element"}}
The above handlebars expression is a standard expression that calls the publish helper. In this use scenario, the returned string is escaped.
Triple-stashed expression
{{{publish element="Content Element"}}}
The above handlebars expression is a triple-stashed expression. Any HTML code returned by standard double-stashed is escaped. If you expect a helper to return HTML code, which you want embedded in the published page, this triple-stashed variant should be used.
-
-
Constructor Summary
Constructors Constructor Description PublishHandlebarsHelper(IElementAPI elementApi)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
apply(Object context, com.github.jknack.handlebars.Options options)
Theapply
method is the main entry point for handlebars.java helpers.
-
-
-
Constructor Detail
-
PublishHandlebarsHelper
@Autowired public PublishHandlebarsHelper(IElementAPI elementApi)
-
-
Method Detail
-
apply
public String apply(Object context, com.github.jknack.handlebars.Options options)
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.
-
-