Sha256: 4601ddc67f77554b458c5af7e24682da84222fd9820959b42324f1f7f4766477
Contents?: true
Size: 428 Bytes
Versions: 3
Compression:
Stored size: 428 Bytes
Contents
module Opal def self.parse_erb(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" "// #{ name } (erb)\n#{ Opal.parse(code) }\n" end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
opal-0.3.33 | lib/opal/erb.rb |
opal-0.3.32 | lib/opal/erb.rb |
opal-0.3.31 | lib/opal/erb.rb |