Sha256: f0c5e93333a2caf91a4c0124c8d3ccbb7244f481ba9b98377f99d5aa934ce62c
Contents?: true
Size: 672 Bytes
Versions: 1
Compression:
Stored size: 672 Bytes
Contents
require 'opal' require 'opal/erb/processor' require 'opal/erb/version' module Opal module ERB 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" "// #{ name } (erb)\n#{ Opal.parse(code) }\n" end end end # Just register our opal code path with opal build tools Opal.append_path File.join(File.dirname(__FILE__), '..', 'assets', 'javascripts')
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
opal-erb-0.0.1 | lib/opal/erb.rb |