Interface Formatter


@Deprecated(since="2024-07-10") public interface Formatter
Deprecated.
com.github.jknack.handlebars package is deprecated and marked for removal in subsequent releases which will involve removal of the handlebars dependency in AEM.

Format a variable to something else. Useful for date/long conversion. etc.. A formatter is applied on simple mustache/handlebars expression, like: {{var}}, but not in block expression.

Usage:


  Handlebars hbs = new Handlebars();

  hbs.with(new Formatter() {
    public Object format(Object value, Chain next) {
     if (value instanceof Date) {
       return ((Date) value).getTime();
     }
     return next.format(value);
    }
  });

  
Since:
2.1.0
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    Deprecated.
    com.github.jknack.handlebars package is deprecated and marked for removal in subsequent releases which will involve removal of the handlebars dependency in AEM.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Formatter.Chain
    Deprecated.
    NOOP Formatter.
  • Method Summary

    Modifier and Type
    Method
    Description
    Deprecated.
    Format a value if possible or call next formatter in the chain.
  • Field Details

  • Method Details

    • format

      Object format(Object value, Formatter.Chain next)
      Deprecated.
      Format a value if possible or call next formatter in the chain.
      Parameters:
      value - A value to format, or pass it to the next formatter in the chain.
      next - Point to the next formatter in the chain.
      Returns:
      A formatted value, not null.