Sha256: 403d5b0ca504fcaf137519f15294c9b71dd6ff22171069f7a9501acf8917de55
Contents?: true
Size: 871 Bytes
Versions: 16
Compression:
Stored size: 871 Bytes
Contents
require 'johnson' class EJSHandler < ActionView::TemplateHandler class EJSProxy # :nodoc: def initialize(controller) @controller = controller end def key?(pooperty) @controller.instance_variables.include?("@#{pooperty}") end def [](pooperty) @controller.instance_variable_get("@#{pooperty}") end def []=(pooperty, value) @controller.instance_variable_set("@#{pooperty}", value) end end def initialize(view) @view = view end def render(template) ctx = Johnson::Runtime.new ctx.evaluate('Johnson.require("johnson/template");') ctx['template'] = template.source ctx['controller'] = @view.controller ctx['at'] = EJSProxy.new(@view.controller) ctx.evaluate('Johnson.templatize(template).call(at)') end end ActionView::Template.register_template_handler("ejs", EJSHandler)
Version data entries
16 entries across 16 versions & 2 rubygems