Add Spree::Money#to_html (from Spree 2.0)

This commit is contained in:
Rohan Mitchell
2016-06-08 16:21:33 +10:00
parent d3a3b2da9a
commit 6546d2763b

View File

@@ -9,4 +9,15 @@ Spree::Money.class_eval do
@options[:no_cents] = true if @money.dollars % 1 == 0
to_s
end
def to_html(options = { :html => true })
output = @money.format(@options.merge(options))
if options[:html]
# 1) prevent blank, breaking spaces
# 2) prevent escaping of HTML character entities
output = output.sub(" ", " ").html_safe
end
output
end
end