Sha256: 4b5f428af01ce77b2507d495474360f87c75ee09f6f5290c87c068a9aa016b25
Contents?: true
Size: 1.21 KB
Versions: 13
Compression:
Stored size: 1.21 KB
Contents
require 'active_support/core_ext' module Wunderbar module Rails class HtmlHandler cattr_accessor :default_format self.default_format = Mime::HTML def self.call(template) %{ 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) %{ 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
13 entries across 13 versions & 1 rubygems