I'm using Haml outside of Rails and need to print out an unescaped string:
%div{ foo: '<?php echo "bar" %>' }
becomes
<div foo='<?php echo "bar" %>'></div>
but I want
<div foo='<?php echo "bar" %>'></div>
raw
and html_safe
are not defined outside of Rails, I tried requiring them and mixing them in, but the end result was the same.
Maybe I'm missing something obvious here...
You need to set the escape_attrs
option to false.
From the command line you can use something like
$ haml --no-escape-attrs my_file.haml
or from Ruby something like:
Haml::Engine.new(my_template, :escape_attrs => false).to_html