lib/nice_partials/partial.rb in nice_partials-0.9.3 vs lib/nice_partials/partial.rb in nice_partials-0.10.0
- old
+ new
@@ -2,10 +2,13 @@
class Partial
autoload :Content, "nice_partials/partial/content"
autoload :Section, "nice_partials/partial/section"
autoload :Stack, "nice_partials/partial/stack"
+ attr_reader :local_assigns
+ alias_method :locals, :local_assigns
+
def initialize(view_context, local_assigns = nil)
@view_context, @local_assigns = view_context, local_assigns
end
def yield(*arguments, &block)
@@ -105,16 +108,26 @@
self.class.define_method(name) { |content = nil, **options, &block| section(name, content, **options, &block) }
self.class.define_method("#{name}?") { section?(name) }
end
def helpers_context
- @helpers_context ||= Helpers.new(@view_context)
+ @helpers_context ||= Helpers.new(@view_context, self)
end
class Helpers < SimpleDelegator
def self.method_added(name)
super
- NicePartials::Partial.delegate name, to: :helpers_context
+
+ unless name == :initialize || name == :partial
+ NicePartials::Partial.delegate name, to: :helpers_context
+ end
+ end
+
+ attr_reader :partial
+
+ def initialize(view_context, partial)
+ super(view_context)
+ @partial = partial
end
end
end
end