Module: Crystal::AbstractController::Render
- Defined in:
- lib/crystal/controller/abstract_controller/render.rb
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- SPECIAL_FORMAT_HANDLERS =
[ ['json', lambda{|o| o.to_json}], ['xml', lambda{|o| o.to_xml}], ['js', lambda{|o| o}], ]
- SPECIAL_CASES_HANDLERS =
[ ['inline', lambda{|o| o}], ]
Instance Method Summary collapse
- #layout(tname = nil) ⇒ Object
- #layout=(layout) ⇒ Object
- #render(*args) ⇒ Object
- #render_action(options) ⇒ Object
Instance Method Details
#layout(tname = nil) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/crystal/controller/abstract_controller/render.rb', line 14 def layout tname = nil if tname @_layout = tname else @_layout end end |
#layout=(layout) ⇒ Object
21 22 23 |
# File 'lib/crystal/controller/abstract_controller/render.rb', line 21 def layout= layout @_layout = layout end |
#render(*args) ⇒ Object
25 26 27 28 |
# File 'lib/crystal/controller/abstract_controller/render.rb', line 25 def render *args = Template.parse_arguments *args render_with_parsed_arguments end |
#render_action(options) ⇒ Object
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 |
# File 'lib/crystal/controller/abstract_controller/render.rb', line 30 def render_action = .to_openobject template = self.class.template_name_for .action return "" unless Template.exist? template instance_variables = {} instance_variable_names.each do |name| instance_variables[name[1..-1]] = instance_variable_get name unless name =~ /^@_/ end = { :template => template, :instance_variables => instance_variables, :context_class => self.class.controller_context_class, :format => params.format, :action => true # this willn't allow to render partial starting with _ }.to_openobject content, context = Template.basic_render layout = .include?(:layout) ? .layout : self.layout if layout content = Template.render_layout layout, :content => content, :context => context end content end |