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 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