Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

There was a problem

You must be a member of this account.

This project is archived and is in readonly mode.

Add options passing to textilze helper

#2973

When rendering textile inside a view using the textilize helper method, it is impossible to pass options to the renderer, which could be very useful if you want to filter HTML or perhaps just want to use lite_mode.

This proposed patch gives the ability to pass options by supplying them after the string like this

textilize("This is worded <strong>strongly</strong>")

=> "<p>This is worded <strong>strongly</strong></p>"




textilize("This is worded <strong>strongly</strong>", :filter_html)

=> "<p>This is worded &lt;strong&gt;strongly&lt;/strong&gt;</p>"




Reported by Magnus Bergmark · July 29th, 2009 @ 02:06 PM

State: resolved
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Matt Jones
    Matt Jones

    The loop over options doesn't make sense - that's nearly the same code that TextileDoc.new executes. Why repeat it?

    July 30th, 2009 @ 02:54 AM

  2. Magnus Bergmark
    Magnus Bergmark

    I agree. It was there in the original code (hardcoded to only :heard_breaks, though) so I thought it was necessary for some form of backwards compatibility.

    I traced back the code and it seems to have appeared 2005 in the SVN repo. A git show on this commit might show people more:

    commit 810ebf7c6a2e9d02f76d8727e56c1706cc6ff66e
    Author: David Heinemeier Hansson <david@loudthinking.com>
    Date:   Sun Oct 2 20:21:43 2005 +0000

    Forced newer versions of RedCloth to use hard breaks [DHH]
    
    git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2436 5ecf4fe2-1ee6-0310-87b1-e25e094e27de</code>
    
    
    
    

    I think this is redundant now. Here's a new patch without this loop. Someone more knowledgeable can choose which patch looks better.

    July 30th, 2009 @ 07:54 AM

  3. Rizwan Reza
    Rizwan Reza
    • Assigned user set to Michael Koziarski
    • Tag changed from 2.3.x, feature_request, helper, patch, text_helper to 2.3.x, bugmash, feature_request, helper, patch, text_helper

    verified

    +1 I have attached an updated patch. There were no test cases in text_helper_test.rb so I added a couple of those.

    August 9th, 2009 @ 03:15 AM

  4. Rizwan Reza
    Rizwan Reza

    verified

    +1 This works on master. I have employed the changes advised by nzkoz.

    August 9th, 2009 @ 03:36 AM

  5. Rizwan Reza
    Rizwan Reza

    verified

    +1 Added one more test for hard_breaks. Refactored.

    August 9th, 2009 @ 03:58 AM

  6. Rizwan Reza
    Rizwan Reza
    • Tag changed from 2.3.x, bugmash, feature_request, helper, patch, text_helper to 3.0, bugmash, feature_request, helper, patch, text_helper

    This is for master branch.

    August 9th, 2009 @ 04:00 AM

  7. Rizwan Reza
    Rizwan Reza

    verified

    By the way, though nzkoz suggests that this should be applied to master.. this passes cleanly on 2-3-stable too.

    August 9th, 2009 @ 04:03 PM

  8. David Trasbo
    David Trasbo

    This patch does not apply to master:

        <stdin>:29: trailing whitespace.
                
        <stdin>:54: trailing whitespace.
          
        <stdin>:58: trailing whitespace.
          
        <stdin>:62: trailing whitespace.
          
        <stdin>:66: trailing whitespace.
          
        error: patch failed: actionpack/lib/action_view/helpers/text_helper.rb:241
        error: actionpack/lib/action_view/helpers/text_helper.rb: patch does not apply
        error: patch failed: actionpack/test/template/text_helper_test.rb:1
        error: actionpack/test/template/text_helper_test.rb: patch does not apply
    

    (With --whitespace=fix)

    August 9th, 2009 @ 04:18 PM

  9. Rizwan Reza
    Rizwan Reza

    Applies cleanly on my side. Just rechecked.

    August 9th, 2009 @ 04:33 PM

  10. Repository
    Repository
    • State changed from new to resolved

    August 9th, 2009 @ 04:43 PM

  11. Repository
  12. David Trasbo
    David Trasbo

    verified

    Must have been something wrong with my clone. Sorry about that.

    August 9th, 2009 @ 04:44 PM

  13. CancelProfileIsBroken
    CancelProfileIsBroken
    • Assigned user cleared.
    • Tag changed from 3.0, bugmash, feature_request, helper, patch, text_helper to 3.0, feature_request, helper, patch, text_helper

    August 9th, 2009 @ 05:13 PM