add blank_html translation so it's possible to use html tags now #43

Merged
merged 1 commit into from May 30, 2012

2 participants

@nashby

closes #29

@rafaelfranca rafaelfranca and 1 other commented on an outdated diff May 30, 2012
lib/show_for/content.rb
@@ -42,5 +42,17 @@ def collection_handler(value, options, &block) #:nodoc:
wrap_with(:collection, response, options)
end
+
+ def translate_blank_html
+ I18n.t(:'show_for.blank_html', :default => translate_blank_text)
+ end
+
+ def translate_blank_text
+ I18n.t(:'show_for.blank', :default => "Not specified")
+ end
+
+ def blank_value(options)
+ options.delete(:if_blank) || translate_blank_html.html_safe
@rafaelfranca
rafaelfranca added a line comment May 30, 2012

I don't think that we need to call html_safe here. Could you test it?

@nashby
nashby added a line comment May 30, 2012

Yeah, I've tested it without html_safe and it was escaped. So I think we need it

@rafaelfranca
rafaelfranca added a line comment May 30, 2012

hmm. Actually I think that we should use ActionView::Helpers::TranslationHelper.translate here

@nashby
nashby added a line comment May 30, 2012

do you mean like this?

diff --git a/lib/show_for/content.rb b/lib/show_for/content.rb
index 4819292..6c44604 100644
--- a/lib/show_for/content.rb
+++ b/lib/show_for/content.rb
@@ -44,7 +44,7 @@ module ShowFor
     end

     def translate_blank_html
-      I18n.t(:'show_for.blank_html', :default => translate_blank_text)
+      template.t(:'show_for.blank_html', :default => translate_blank_text)
     end

     def translate_blank_text
@@ -52,7 +52,7 @@ module ShowFor
     end

     def blank_value(options)
-      options.delete(:if_blank) || translate_blank_html.html_safe
+      options.delete(:if_blank) || translate_blank_html
     end
   end
 end
@rafaelfranca
rafaelfranca added a line comment May 30, 2012

Yes.

@nashby
nashby added a line comment May 30, 2012

Pushed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@rafaelfranca rafaelfranca merged commit 990ad51 into plataformatec:master May 30, 2012
@rafaelfranca

Thank you ❤️

@nashby

Yay! 😆

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment