Class SelectedValuesHandlebarsHelper
- java.lang.Object
-
- com.terminalfour.publish.handlebars.helper.BaseHelper
-
- com.terminalfour.publish.handlebars.helper.content.element.list.SelectedValuesHandlebarsHelper
-
- All Implemented Interfaces:
com.github.jknack.handlebars.Helper<Object>
@Component public class SelectedValuesHandlebarsHelper extends BaseHelper
The {{selectedValues ...}} handlebars helper is used to output the selected values 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 bothselectedNames
andselectedValues
helpers.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
{{selectedValues element="List Content Element"}}
The above handlebars expression will output the selected list values 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>{{{selectedValues 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 SelectedValuesHandlebarsHelper(IElementAPI elementApi, IListAPI listApi)
-
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
-
SelectedValuesHandlebarsHelper
@Autowired public SelectedValuesHandlebarsHelper(IElementAPI elementApi, IListAPI listApi)
-
-
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.
-
-