From dc95adfe5335e4c57cc869f62f0eaa045e198427 Mon Sep 17 00:00:00 2001 From: Alex Sharp Date: Thu, 6 Jun 2013 15:47:24 -0700 Subject: [PATCH 1/2] over-ride Tilt#compiled_method method to avoid template caching --- lib/bldr/template.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/bldr/template.rb b/lib/bldr/template.rb index 4e218c6..36c8967 100644 --- a/lib/bldr/template.rb +++ b/lib/bldr/template.rb @@ -24,6 +24,11 @@ def prepare def precompiled_template(locals) data.to_s end + + protected + def compiled_method(locals_keys) + compile_template_method(locals_keys) + end end Tilt.register 'bldr', Bldr::Template From 182ac56e0156983b1d22aa23729bea2ecc500ed2 Mon Sep 17 00:00:00 2001 From: Alex Sharp Date: Tue, 11 Jun 2013 02:39:22 -0700 Subject: [PATCH 2/2] Don't copy over most sinatra instance variables --- lib/bldr/node.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/bldr/node.rb b/lib/bldr/node.rb index b1a5d87..0c8e66c 100644 --- a/lib/bldr/node.rb +++ b/lib/bldr/node.rb @@ -7,6 +7,7 @@ class Node # These do not get copied into child nodes. All other instance variables do. PROTECTED_IVARS = [:@current_object, :@result, :@parent, :@opts, :@views, :@locals] + SINATRA_IVARS = [:@default_layout, :@app, :@template_cache, :@env, :@response] # List of bldr public api method. So we don't overwrite them when we do # crazy ruby metaprogramming when we build nodes. @@ -314,7 +315,7 @@ def template(template, options={}) # # @param [Object] object The object to copy instance variables from. def copy_instance_variables(object) - ivar_names = (object.instance_variables - PROTECTED_IVARS).map(&:to_s) + ivar_names = (object.instance_variables - PROTECTED_IVARS - SINATRA_IVARS).map(&:to_s) ivar_names.map do |name| instance_variable_set(name, object.instance_variable_get(name)) end