public Method

TagHelper.escape_once(html)

Returns an escaped version of html without affecting existing escaped entities.

Examples

escape_once("1 > 2 & 3")
# => "1 < 2 & 3"

escape_once("<< Accept & Checkout")
# => "<< Accept & Checkout"

Source Code

# File action_view/helpers/tag_helper.rb, line 101
def escape_once(html)
  html.to_s.gsub(/[\"><]|&(?!([a-zA-Z]+|(#\d+));)/) { |special| ERB::Util::HTML_ESCAPE[special] }
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.