From 6546d2763b4d22c55e7dd8942e16f9312366e39b Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Wed, 8 Jun 2016 16:21:33 +1000 Subject: [PATCH] Add Spree::Money#to_html (from Spree 2.0) --- lib/spree/money_decorator.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/spree/money_decorator.rb b/lib/spree/money_decorator.rb index fc249151f4..755041df0e 100644 --- a/lib/spree/money_decorator.rb +++ b/lib/spree/money_decorator.rb @@ -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