Class PreviewHandlebarsHelper
- java.lang.Object
-
- com.terminalfour.publish.handlebars.helper.BaseHelper
-
- com.terminalfour.publish.handlebars.helper.page.PreviewHandlebarsHelper
-
- All Implemented Interfaces:
com.github.jknack.handlebars.Helper<Object>
@Component public class PreviewHandlebarsHelper extends BaseHelper
The {{#preview}} handlebars helper is a simple helper to allow processing of blocks to in preview only.Usage
The preview handlebars helper is a block level helper. It allows blocks to be processed based on whether the current context is preview or not.
Example
{{#preview}} <div class="t4-info"> <span class="t4-channel">This is a preview of {{channelName}}</span> <span class="t4-publish-url">Publish URL<br />{{publishURL}}</span> </div> {{else}} <!-- Output something to the published page --> {{/preview}}
In the above example, in preview only, a div is output with the name of the Channel and the URL of the published page.
-
-
Constructor Summary
Constructors Constructor Description PreviewHandlebarsHelper(IPageAPI pageApi, IHandlebarsAPI handlebarsApi)
-
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
-
PreviewHandlebarsHelper
@Autowired public PreviewHandlebarsHelper(IPageAPI pageApi, IHandlebarsAPI handlebarsApi)
-
-
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.
-
-