module MithrilRails::MSX
Public Class Methods
context()
click to toggle source
# File lib/mithril_rails/msx.rb, line 7 def self.context # lazily loaded during first request and reloaded every time when in dev or test unless @context && ::Rails.env.production? contents = # If execjs uses therubyracer, there is no 'global'. Make sure # we have it so JSX script can work properly. 'var global = global || this;' + # search for transformer file using sprockets - allows user to override # this file in his own application File.read(::Rails.application.assets.resolve('MSXTransformer.js')) @context = ExecJS.compile(contents) end @context end
transform(code)
click to toggle source
# File lib/mithril_rails/msx.rb, line 25 def self.transform(code) result = context.call('JSXTransformer.transform', code) return result['code'] end