Module: RubyApp::Mixins::RenderMixin
Instance Method Summary collapse
- #content_for(format, name, value = nil, &block) ⇒ Object
- #get_cache(format) ⇒ Object
- #get_default_template ⇒ Object
- #get_templates(format) ⇒ Object
- #render(format) ⇒ Object
Instance Method Details
#content_for(format, name, value = nil, &block) ⇒ Object
25 26 27 |
# File 'lib/ruby_app/mixins/render_mixin.rb', line 25 def content_for(format, name, value = nil, &block) return RubyApp::Response.content_for(self, format, name, value, &block) end |
#get_cache(format) ⇒ Object
21 22 23 |
# File 'lib/ruby_app/mixins/render_mixin.rb', line 21 def get_cache(format) return self.is_a?(Class) ? super(format) : self.class.get_cache(format) end |
#get_default_template ⇒ Object
17 18 19 |
# File 'lib/ruby_app/mixins/render_mixin.rb', line 17 def get_default_template return self.is_a?(Class) ? super : self.class.get_default_template end |
#get_templates(format) ⇒ Object
13 14 15 |
# File 'lib/ruby_app/mixins/render_mixin.rb', line 13 def get_templates(format) return self.is_a?(Class) ? super(format) : self.class.get_templates(format) end |
#render(format) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/ruby_app/mixins/render_mixin.rb', line 29 def render(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]) if self.block_is_haml?(_content) self.capture_haml(arguments, &_content) 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 end |