lib/spontaneous/output/context.rb in spontaneous-0.2.0.beta5 vs lib/spontaneous/output/context.rb in spontaneous-0.2.0.beta6
- old
+ new
@@ -28,12 +28,12 @@
def root
site.home
end
- def site_page(path)
- site[path]
+ def home
+ site.home
end
def asset_environment
_with_render_cache('asset.environment') do
Spontaneous::Asset::Environment.new(self)
@@ -105,10 +105,11 @@
# layout that you used in the static list
def template(template_path)
__loader.template(template_path).convert(Spontaneous::Output::Template::RequestSyntax)
end
+ # 'defer' is a useful semantic way of calling 'template'
alias_method :defer, :template
def __format
__loader.format
end
@@ -119,16 +120,22 @@
param = __render_content(param) #render(param, param.template)
end
param.to_s
end
+ RENDER_METHODS = [:render_inline_using, :render_using, :render_inline, :render].freeze
+
# Has to be routed through the top-level renderer so as to make
# use of shared caches that are held by it.
def __render_content(content)
- if content.respond_to?(:render_using)
- content.render_using(_renderer, __format, {}, self)
- else
- content.render(__format, {}, self)
+ case (method = RENDER_METHODS.detect { |m| content.respond_to?(m) })
+ # use #__send__ to ensure that the method goes to any Renderable proxy object directly
+ when :render_inline_using, :render_using
+ content.__send__(method, _renderer, __format, {}, self)
+ when :render_inline, :render
+ content.__send__(method, __format, {}, self)
+ else # fallback to showing nothing
+ ""
end
end
end
module PublishContext