Closed gavinmcfarland closed 12 years ago
html_safe
is a Rails method, you will need to require string extensions in your controller.rb
:
require 'active_support/core_ext/string'
I see. Thanks Winton. :)
Hi. I required the correct library but found I was having the same problem, where it was saying the method was undefined. I found using html_escape
works but only like the following...
def code(code)
html_escape(code)
end
This unfortunately means I have to write in my views like this...
= code('<div class="test">test</div>')
I'd like to be able to write the view like this...
- code do
<div class"test">test</div>
When I write it like this the HTML is no longer escaped
This is what I'm using for that block.
def code
html_escape(yield)
end
Any thoughts on why the method isn't working in the haml view?
There are a few ways in HAML to do what you are doing without writing your own helper. Suggest you look here:
Hi,
I'm trying to create a helper that escapes html for but unfortunately it says the method
html_safe
is undefined.Am I writing this correctly?
This is what I have...