Sha256: 29f473203757efdf77657b1842bd3400b18c769a37fbd8999a4d0d890a35c5de
Contents?: true
Size: 1.26 KB
Versions: 5
Compression:
Stored size: 1.26 KB
Contents
require 'active_support/core_ext' require 'action_view' module Wunderbar module Rails class HtmlHandler cattr_accessor :default_format self.default_format = Mime[:html] def self.call(template, source=nil) %{ compiled = Proc.new {#{template.source}} x = Wunderbar::HtmlMarkup.new(self); instance_variables.each do |var| x.instance_variable_set var, instance_variable_get(var) end x.instance_eval(&compiled) x._.target! }.strip # take care to preserve line numbers in original source end end class JsonHandler cattr_accessor :default_format self.default_format = Mime[:json] def self.call(template, source=nil) %{ compiled = Proc.new {#{template.source}} x = Wunderbar::JsonBuilder.new(self); instance_variables.each do |var| x.instance_variable_set var, instance_variable_get(var) end x.instance_eval(&compiled) x.target! }.strip # take care to preserve line numbers in original source end end ActionView::Template.register_template_handler :_html, HtmlHandler ActionView::Template.register_template_handler :_json, JsonHandler end end
Version data entries
5 entries across 5 versions & 1 rubygems