heartcombo/show_for

escape tag problems

Marmolin opened this issue · 8 comments

When using your excellent show_for in a rails 3.1 application as follows

         <%= u.association :groups, :using => :name %>

the result is

Groups:

<li>Basgrupp Öst</li>

I think you forgot to add html_safe to some content_tag. If you have content in content each part has t have a html_safe according to my experience

Sorry, I think part of your code was escaped by Github. Could you please post again?

What do you mean with post again ?

The only code on this matter is , that is when one has an has many association the show_for do not display a list but e.g the text

           <li>Basgrupp Öst</li>

i.e show_for do not use html_safe on association lists

Could you please check if you've changed the default_collection_proc config in your show_for initializer file? ShowFor's default is:

    @@default_collection_proc = lambda { |value| "<li>#{ERB::Util.html_escape(value)}</li>".html_safe }

But the initializer that's copied to your application has this example:

  # The default iterator to be used when invoking a collection/association.
  # config.default_collection_proc = lambda { |value| "<li>#{value}</li>" }

Which does not contain the escape/html safe part, that might be the issue. I'll update the template with the proper fix, but please check your config. Thanks.

I have used the he default iterator to be used when invoking a collection/association

config.default_collection_proc = lambda { |value| "
  • #{value}
  • " }

    I think that was the default in the configuration file I got

    I have now changed it as you suggested and it works


    Hans Marmolin
    St: Larsgatan 50, 58224 Linkping, Sweden
    Phone: +46708371202

    25 jan 2012 kl. 01.24 skrev Carlos Antonio da Silva:

    Could you please check if you've changed the default_collection_proc config in your show_for initializer file? ShowFor's default is:

       @@default_collection_proc = lambda { |value| "<li>#{ERB::Util.html_escape(value)}</li>".html_safe }

    But the initializer that's copied to your application has this example:

     # The default iterator to be used when invoking a collection/association.
     # config.default_collection_proc = lambda { |value| "<li>#{value}</li>" }

    Which does not contain the escape/html safe part, that might be the issue. I'll update the template with the proper fix, but please check your config. Thanks.


    Reply to this email directly or view it on GitHub:
    #29 (comment)

    Carlos
    Would it be possible to configure the key for blank content or to have html_blank instead
    It is now blank but of one could configure it or it was blank_html then any styling could be done of the text in blank field


    Hans Marmolin
    St: Larsgatan 50, 58224 Linkping, Sweden
    Phone: +46708371202

    25 jan 2012 kl. 01.24 skrev Carlos Antonio da Silva:

    Could you please check if you've changed the default_collection_proc config in your show_for initializer file? ShowFor's default is:

       @@default_collection_proc = lambda { |value| "<li>#{ERB::Util.html_escape(value)}</li>".html_safe }

    But the initializer that's copied to your application has this example:

     # The default iterator to be used when invoking a collection/association.
     # config.default_collection_proc = lambda { |value| "<li>#{value}</li>" }

    Which does not contain the escape/html safe part, that might be the issue. I'll update the template with the proper fix, but please check your config. Thanks.


    Reply to this email directly or view it on GitHub:
    #29 (comment)

    Glad to know it's working now. Btw, I forgot to ask which version are you using?

    About blank values, I think they can be configured in your locale file generated by ShowFor.

    I use the gem specification in bundle
    gem 'show_for'
    so I suppose the last version will be included.
    My version is show_for (0.2.4)

    You cannot use html-tags in the locale file if you dont has a blank_html key or or add a html key, I think. One cannot ad .html_safe to the yaml file.
    This is what is needed
    sv:
    show_for:
    blank:
    html: "; Inte angiven"
    "yes": "Ja"
    "no": "Nej"

    or

    sv:
    show_for:
    blank_html: "; Inte angiven"
    "yes": "Ja"
    "no": "Nej"

    and that should require some change in the code


    Hans Marmolin
    St: Larsgatan 50, 58224 Linköping, Sweden
    Phone: +46708371202

    25 jan 2012 kl. 11.49 skrev Carlos Antonio da Silva:

    Glad to know it's working now. Btw, I forgot to ask which version are you using?

    About blank values, I think they can be configured in your locale file generated by ShowFor.


    Reply to this email directly or view it on GitHub:
    #29 (comment)

    It is possible to use html in the yaml files, but the *_html version which automatically converts to html_safe is only provided by Rails. I'll check how it's working today and what we have to change to make it work with html. Thanks.