Module: RubyApp::Mixins::RenderMixin
Instance Method Summary collapse
- #content_for(name, value = nil, &block) ⇒ Object
- #render(format) ⇒ Object
- #rendered?(file) ⇒ Boolean
- #templates(format) ⇒ Object
Instance Method Details
#content_for(name, value = nil, &block) ⇒ Object
24 25 26 |
# File 'lib/ruby_app/mixins/render_mixin.rb', line 24 def content_for(name, value = nil, &block) return RubyApp::Response.content_for(self, name, value, &block) end |
#render(format) ⇒ Object
28 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 |
# File 'lib/ruby_app/mixins/render_mixin.rb', line 28 def render(format) templates = self.templates(format) unless templates.empty? self.init_haml_helpers unless @haml_buffer begin yield(self) if block_given? templates.each_with_index do |template, index| content = Haml::Engine.new(File.read(template), :filename => template).render(self) do |*arguments| if arguments.empty? index == 0 ? nil : RubyApp::Response.get_content(self, templates[index - 1]) else _content = RubyApp::Response.get_content(self, arguments[0]) if self.block_is_haml?(_content) self.capture_haml(arguments, &_content) else _content end end end RubyApp::Response.content_for(self, template, content) end return RubyApp::Response.get_content(self, templates.last) ensure RubyApp::Response.clear_content(self) end end end |
#rendered?(file) ⇒ Boolean
17 18 19 20 21 22 |
# File 'lib/ruby_app/mixins/render_mixin.rb', line 17 def rendered?(file) unless RubyApp::Response.rendered?(file) yield RubyApp::Response.rendered(file) end end |
#templates(format) ⇒ Object
13 14 15 |
# File 'lib/ruby_app/mixins/render_mixin.rb', line 13 def templates(format) return self.is_a?(Class) ? self.get_templates(format) : self.class.get_templates(format) end |