Class SelectedNamesHandlebarsHelper
- java.lang.Object
-
- com.terminalfour.publish.handlebars.helper.BaseHelper
-
- com.terminalfour.publish.handlebars.helper.content.element.list.SelectedNamesHandlebarsHelper
-
- All Implemented Interfaces:
com.github.jknack.handlebars.Helper<Object>
@Component public class SelectedNamesHandlebarsHelper extends BaseHelper
The {{selectedNames ...}} handlebars helper is used to output the selected names of a List Content Element.The helper allows the developer to configure the separators that are used.
Separators
There are two possible separators defined on bothselectedNamesandselectedValueshelpers.Attribute Description Default value Example separator This is the separator that is output between each selection , (<comma><space>) Ireland, USA, UK level-separator This is the separator that is output between each entry within a single selection, where the selection is multi-level > USA>California>San Diego Usage
{{selectedNames element="List Content Element"}}The above handlebars expression will output the selected list names using the default separators. This is equivalent to the below expression.
{{publish element="List Content Element"}}However, the output can be customized using the two separator attribute described above.
{{#ifSet element="List Content Element}} <ul> <li>{{{selectedNames element="List Content Element" separator="</li><li>" level-separator=" ⇒ "}}}</li> </ul> {{/ifSet}}In the above example, if the List Content Element has any selections made on it, they will be output within an unordered list, as per the example below.
<ul> <li>USA ⇒ California ⇒ San Diego</li> <li>Ireland ⇒ Dublin</li> </ul>
-
-
Constructor Summary
Constructors Constructor Description SelectedNamesHandlebarsHelper(IElementAPI elementApi, IListAPI listApi)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringapply(Object context, com.github.jknack.handlebars.Options options)Theapplymethod is the main entry point for handlebars.java helpers.
-
-
-
Constructor Detail
-
SelectedNamesHandlebarsHelper
@Autowired public SelectedNamesHandlebarsHelper(IElementAPI elementApi, IListAPI listApi)
-
-
Method Detail
-
apply
public String apply(Object context, com.github.jknack.handlebars.Options options)
Description copied from class:BaseHelperTheapplymethod 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:
applyin interfacecom.github.jknack.handlebars.Helper<Object>- Specified by:
applyin classBaseHelper- Parameters:
context- The currently executing context.options- The options.- Returns:
- The generated output.
-
-