Class NeqHandlebarsHelper
- java.lang.Object
-
- com.terminalfour.publish.handlebars.helper.BaseHelper
-
- com.terminalfour.publish.handlebars.helper.utility.NeqHandlebarsHelper
-
- All Implemented Interfaces:
com.github.jknack.handlebars.Helper<Object>
@Component public class NeqHandlebarsHelper extends BaseHelper
The {{neq ...}} handlebars helper extends the core neq that is provided as part of handlebars.java.This extended version checks if two values are different.
Usage
The {{neq ...}} helper takes the following format.
{{[#]neq [value1] [value2]}}
Attributes
- #: should be added before the helper name when using it as a block expression, otherwise will be considered as standard expression.
- value1: string/numeric value or handlebars expression. For example "first value" or (nav id="2").
- value2: string/numeric value or handlebars expression. For example "second value" or (nav id="3").
Examples
Block expression
{{#neq value1 value2}} <p>To be displayed when they are not equal</p> {{else}} <p>To be displayed when they are equal</p> {{/neq}}
This would return <p>To be displayed when they are not equal</p> in case the values are not equal, otherwise <p>To be displayed when they are equal</p>.
Standard expression
{{#or (neq value1 value2) (neq value1 value3)}} <p>To be displayed when they any not equal</p> {{/or}}
This would return <p>To be displayed when they are not equal</p> in case any of the two neq expressions are true (their values are not equal).
-
-
Constructor Summary
Constructors Constructor Description NeqHandlebarsHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
apply(Object value1, com.github.jknack.handlebars.Options options)
Theapply
method is the main entry point for handlebars.java helpers.
-
-
-
Method Detail
-
apply
public Object apply(Object value1, 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:
value1
- The currently executing context.options
- The options.- Returns:
- The generated output.
- Throws:
IOException
- If processing of the expressions fails.
-
-