Class: Haml::Filters::Ruby2JS
- Inherits:
-
Base
- Object
- Base
- Haml::Filters::Ruby2JS
- Defined in:
- lib/ruby2js/haml.rb
Instance Method Summary collapse
- #compile(node) ⇒ Object
-
#compile_ruby!(temple, node) ⇒ Object
Copird from text base, added ruby2js convert.
Instance Method Details
#compile(node) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/ruby2js/haml.rb', line 26 def compile(node) temple = [:multi] temple << [:static, "<script type='text/javascript'>\n"] compile_ruby!( temple , node ) temple << [:static, "\n</script>"] temple end |
#compile_ruby!(temple, node) ⇒ Object
Copird from text base, added ruby2js convert
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/ruby2js/haml.rb', line 35 def compile_ruby!(temple, node) text = node.value[:text] if ::Haml::Util.contains_interpolation?(node.value[:text]) # original: Haml::Filters#compile text = ::Haml::Util.unescape_interpolation(text).gsub(/(\\+)n/) do |s| escapes = $1.size next s if escapes % 2 == 0 "#{'\\' * (escapes - 1)}\n" end text.prepend("\n") temple << [:dynamic, "::Ruby2JS.convert(#{text} ).to_s"] else temple << [:static, ::Ruby2JS.convert(text).to_s] end end |