Skip to content

Instantly share code, notes, and snippets.

@hampusn
Created July 3, 2014 09:13
Show Gist options
  • Save hampusn/ed78ca099406dfb8ceab to your computer and use it in GitHub Desktop.
Save hampusn/ed78ca099406dfb8ceab to your computer and use it in GitHub Desktop.
Liquid filter which formats a float with two decimals. Example usage: <p>Price: {{ 95.5 | hampusn_money }}</p>
module Jekyll
module HampusnMoneyFilter
def hampusn_money(money)
return '' if money.nil?
sprintf("%0.02f", money)
end
end
end
Liquid::Template.register_filter(Jekyll::HampusnMoneyFilter)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment