lib/ruby_app/mixins/render_mixin.rb in RubyApp-0.2.7 vs lib/ruby_app/mixins/render_mixin.rb in RubyApp-0.2.8
- old
+ new
@@ -8,40 +8,43 @@
module Mixins
module RenderMixin
require 'ruby_app'
- def cache(format)
- return self.is_a?(Class) ? self.get_cache(format) : self.class.get_cache(format)
+ def get_templates(format)
+ return self.is_a?(Class) ? super(format) : self.class.get_templates(format)
end
- def templates(format)
- return self.is_a?(Class) ? self.get_templates(format) : self.class.get_templates(format)
+ def get_default_template
+ return self.is_a?(Class) ? super : self.class.get_default_template
end
- def rendered?(file)
- unless RubyApp::Response.rendered?(file)
- yield
- RubyApp::Response.rendered(file)
- end
+ def get_cache(format)
+ return self.is_a?(Class) ? super(format) : self.class.get_cache(format)
end
def content_for(format, name, value = nil, &block)
return RubyApp::Response.content_for(self, format, name, value, &block)
end
def render(format)
- templates = self.templates(format)
+ templates = self.get_templates(format)
unless templates.empty?
self.init_haml_helpers unless @haml_buffer
yield(self) if block_given?
templates.each_with_index do |template, index|
+
+ if RubyApp::Response.rendered?(self, template)
+ template = self.get_default_template
+ templates[index] = template
+ end
+
content = Haml::Engine.new(File.read(template), :filename => template).render(self) do |*arguments|
if arguments.empty?
index == 0 ? nil : RubyApp::Response.get_content(self, format, templates[index - 1])
else
_content = RubyApp::Response.get_content(self, format, arguments[0])
@@ -50,10 +53,13 @@
else
_content
end
end
end
+
+ RubyApp::Response.rendered(self, template)
RubyApp::Response.content_for(self, format, template, content)
+
end
return RubyApp::Response.get_content(self, format, templates.last)
end