module Opal::ERB
Constants
- VERSION
Public Class Methods
parse(str, name='(erb)')
click to toggle source
# File lib/opal/erb.rb, line 7 def self.parse(str, name='(erb)') body = str.gsub('"', '\\"').gsub(/<%=([\s\S]+?)%>/) do inner = $1.gsub(/\\'/, "'").gsub(/\\"/, '"') "\")\nout.<<(#{ inner })\nout.<<(\"" end.gsub(/<%([\s\S]+?)%>/) do "\")\n#{ $1 }\nout.<<(\"" end code = "ERB.new('#{name}') do\nout = []\nout.<<(\"#{ body }\")\nout.join\nend\n" Opal.parse code end