Created
July 3, 2014 09:13
-
-
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>
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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