java.lang.Object
java.lang.Enum<NumberHelper>
com.github.jknack.handlebars.helper.ext.NumberHelper
All Implemented Interfaces:
com.github.jknack.handlebars.Helper<Object>, Serializable, Comparable<NumberHelper>, Constable

public enum NumberHelper extends Enum<NumberHelper> implements com.github.jknack.handlebars.Helper<Object>
Commons number function helpers.
Author:
https://github.com/Jarlakxen
  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    You can use the isEven helper to return a value only if the first argument is even.
    You can use the isOdd helper to return a value only if the first argument is odd.
    You can use the stripes helper to return different value if the passed argument is odd or even.
  • Method Summary

    Modifier and Type
    Method
    Description
    apply(Object context, com.github.jknack.handlebars.Options options)
     
    static void
    register(com.github.jknack.handlebars.Handlebars handlebars)
    Register all the number helpers.
    void
    registerHelper(com.github.jknack.handlebars.Handlebars handlebars)
    Register the helper in a handlebars instance.
    Returns the enum constant of this class with the specified name.
    static NumberHelper[]
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class java.lang.Enum

    compareTo, describeConstable, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • isEven

      public static final NumberHelper isEven
      You can use the isEven helper to return a value only if the first argument is even. Otherwise return null.
      
       <li class="{{isEven value "leftBox"}}">
       
      If value is 2, the output will be "leftBox".
    • isOdd

      public static final NumberHelper isOdd
      You can use the isOdd helper to return a value only if the first argument is odd. Otherwise return null.
      
       <li class="{{isOdd value "rightBox"}}">
       
      If value is 3, the output will be "rightBox".
    • stripes

      public static final NumberHelper stripes
      You can use the stripes helper to return different value if the passed argument is odd or even.
      
       <tr class="{{stripes value "row-even" "row-odd"}}">
       
      If value is 2, the output will be "row-even".
  • Method Details

    • values

      public static NumberHelper[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static NumberHelper valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • apply

      public Object apply(Object context, com.github.jknack.handlebars.Options options) throws IOException
      Specified by:
      apply in interface com.github.jknack.handlebars.Helper<Object>
      Throws:
      IOException
    • registerHelper

      public void registerHelper(com.github.jknack.handlebars.Handlebars handlebars)
      Register the helper in a handlebars instance.
      Parameters:
      handlebars - A handlebars object. Required.
    • register

      public static void register(com.github.jknack.handlebars.Handlebars handlebars)
      Register all the number helpers.
      Parameters:
      handlebars - The helper's owner. Required.