Package liqp.filters

Class Filter

java.lang.Object
liqp.LValue
liqp.filters.Filter
Direct Known Subclasses:
Abs, Append, At_Least, At_Most, Capitalize, Ceil, Compact, Concat, Date, Default, Divided_By, Downcase, Escape, Escape_Once, First, Floor, H, Join, Json, Last, Lstrip, Map, Minus, Modulo, Newline_To_Br, Normalize_Whitespace, Plus, Pop, Prepend, Push, Relative_Url, Remove, Remove_First, Replace, Replace_First, Reverse, Round, Rstrip, Shift, Size, Slice, Sort, Sort_Natural, Split, Strip, Strip_HTML, Strip_Newlines, Times, Truncate, Truncatewords, Uniq, Unshift, Upcase, Url_Decode, Url_Encode, Where, Where_Exp

public abstract class Filter extends LValue
Output markup takes filters. Filters are simple methods. The first parameter is always the output of the left side of the filter. The return value of the filter will be the new left value when the next filter is run. When there are no more filters, the template will receive the resulting string.

-- https://github.com/Shopify/liquid/wiki/Liquid-for-Designers

  • Field Details

    • name

      public final String name
      The name of the filter.
  • Constructor Details

    • Filter

      protected Filter()
      Used for all package protected filters in the liqp.filters-package whose name is their class name lower cased.
    • Filter

      public Filter(String name)
      Creates a new instance of a Filter.
      Parameters:
      name - the name of the filter.
  • Method Details

    • getName

      public String getName()
      Returns the name of the filter.
      Returns:
      The name.
    • apply

      public Object apply(Object value, TemplateContext context, Object... params)
      Applies the filter on the 'value', with the given 'context'.
      Parameters:
      value - the string value `AAA` in: `{{ 'AAA' | f:1,2,3 }}`
      context - the template context.
      params - the values [1, 2, 3] in: `{{ 'AAA' | f:1,2,3 }}`
      Returns:
      the result of the filter.
    • get

      protected Object get(int index, Object... params)
      Returns a value at a specific index from an array of parameters. If no such index exists, a RuntimeException is thrown.
      Parameters:
      index - the index of the value to be retrieved.
      params - the values.
      Returns:
      a value at a specific index from an array of parameters.