« lib/WWW/Shopify/Liquid/Operator/Regex.pm
↑ Summary
lib/WWW/Shopify/Liquid/Dialect/Shopify/Filter/MoneyWithoutTrailingZeros.pm »
| 1 | #!/usr/bin/perl | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | |||
| 5 | package WWW::Shopify::Liquid::Dialect::Shopify::Filter::Money; use base 'WWW::Shopify::Liquid::Filter'; | ||
| 6 | sub operate { | ||
| 7 | return undef unless $_[2]; | ||
| 8 | my $format = $_[1]->{shop}->{money_format}; | ||
| 9 | $format = '$ {{ amount }}' unless $format; | ||
| 10 | my $amount = sprintf('%.2f', $_[2] / 100.0); | ||
| 11 | $format =~ s/\{\{\s*amount\s*\}\}/$amount/; | ||
| 12 | return $format; | ||
| 13 | } | ||
| 14 | 1; |