Skip to content

Filter doesn't work #32

Description

@zimt28

One of my filters doesn't work, and I can't figure out why. Every other filter seems to work, but the date filter in the following example doesn't work, even if I change its name to something else.

defmodule Test.LiquidFilters do
  def date(date) do
    Timex.format!(date, "%d.%m.%Y", :strftime)
  end

  def add_ten(value) do
    value + 10
  end
end

defmodule Test do
  def run do
    Liquid.Filters.add_filters(Test.LiquidFilters)
    
    data =
      %{
        "my_date" => Ecto.DateTime.utc(),
        "my_int" => 32
      }
    
    template = 
      """
        {{ my_date | date }} <br />
        {{ my_int | add_ten }}
      """

    {:ok, output, _} =
      template
      |> Liquid.Template.parse
      |> Liquid.Template.render(data)

    output
  end
end
iex(1)> Test.run()
"  2017-06-14 18:00:00 <br />\n  42\n"
iex(2)> Ecto.DateTime.utc() |> Timex.format!("%d.%m.%Y", :strftime)
"14.06.2017"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions