Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

escape tag problems #29

Closed
Marmolin opened this Issue Jan 21, 2012 · 8 comments

Comments

Projects
None yet
3 participants
Contributor

Marmolin commented Jan 21, 2012

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

Collaborator

carlosantoniodasilva commented Jan 24, 2012

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

Contributor

Marmolin commented Jan 25, 2012

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

@Marmolin Marmolin closed this Jan 25, 2012

Collaborator

carlosantoniodasilva commented Jan 25, 2012

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.

Contributor

Marmolin commented Jan 25, 2012

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)

    Contributor

    Marmolin commented Jan 25, 2012

    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)

    Collaborator

    carlosantoniodasilva commented Jan 25, 2012

    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.

    Contributor

    Marmolin commented Jan 25, 2012

    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)

    Collaborator

    carlosantoniodasilva commented Jan 25, 2012

    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.

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