Module: Brakeman::FakeHamlFilter
- Included in:
- Haml::Filters::Coffee, Haml::Filters::Markdown, Haml::Filters::Sass
- Defined in:
- lib/brakeman/parsers/haml_embedded.rb
Instance Method Summary collapse
-
#compile(compiler, text) ⇒ Object
Copied from Haml 4 - force delayed compilation.
Instance Method Details
#compile(compiler, text) ⇒ Object
Copied from Haml 4 - force delayed compilation
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/brakeman/parsers/haml_embedded.rb', line 4 def compile(compiler, text) filter = self compiler.instance_eval do text = unescape_interpolation(text).gsub(/(\\+)n/) do |s| escapes = $1.size next s if escapes % 2 == 0 ("\\" * (escapes - 1)) + "\n" end # We need to add a newline at the beginning to get the # filter lines to line up (since the Haml filter contains # a line that doesn't show up in the source, namely the # filter name). Then we need to escape the trailing # newline so that the whole filter block doesn't take up # too many. text = "\n" + text.sub(/\n"\Z/, "\\n\"") push_script <<RUBY.rstrip, :escape_html => false find_and_preserve(#{filter.inspect}.render_with_options(#{text}, _hamlout.options)) RUBY return end end |