Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

escape tag problems #29

Closed
Marmolin opened this issue Jan 21, 2012 · 8 comments · Fixed by #43
Closed

escape tag problems #29

Marmolin opened this issue Jan 21, 2012 · 8 comments · Fixed by #43

Comments

@Marmolin
Copy link
Contributor

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

@carlosantoniodasilva
Copy link
Member

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

@Marmolin
Copy link
Contributor Author

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

@carlosantoniodasilva
Copy link
Member

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.

@Marmolin
Copy link
Contributor Author

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)

    @Marmolin
    Copy link
    Contributor Author

    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)

    @carlosantoniodasilva
    Copy link
    Member

    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.

    @Marmolin
    Copy link
    Contributor Author

    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)

    @carlosantoniodasilva
    Copy link
    Member

    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
    Labels
    None yet
    Development

    Successfully merging a pull request may close this issue.

    3 participants