Class: ActionController::Base

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::TextHelper
Defined in:
lib/base.rb

Instance Method Summary collapse

Instance Method Details

#check_mdml(action = nil) ⇒ Object



43
44
45
46
47
48
49
50
# File 'lib/base.rb', line 43

def check_mdml(action = nil)
  begin
    handle_mdml(view_class, action)
  rescue Exception => e
    logger.error(e)
    render_text "<h1>Exception</h1> <pre>#{ERB::Util.h(e.to_s)}\n#{e.backtrace.join("\n")}</pre>"
  end 
end

#handle_mdml(view_class, action = nil) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/base.rb', line 64

def handle_mdml(view_class, action = nil)
  action ||= self.action_name
  vc = self.view_class
  return false unless vc and vc.public_method_defined?(action)
  view = vc.new
  view.controller = self
  add_variables_to_assigns
  view.load_assigns(@assigns)
  html = Persia::Element.new 'html'
  cursor = Persia::Cursor.create_element(html, view)
  view.send(action, cursor)
  render_text cursor.to_s
end

#render_action(action_name, status = nil, with_layout = true) ⇒ Object

original version of method in actionpack 1.12.5 def render_action(action_name, status = nil, with_layout = true) #:nodoc:

template = default_template_name(action_name.to_s)
if with_layout && !template_exempt_from_layout?(template) 
  render_with_layout(template, status)
else
  render_without_layout(template, status)
end

end



33
34
35
36
37
38
39
40
41
# File 'lib/base.rb', line 33

def render_action(action_name, status = nil, with_layout = true) #:nodoc:
  r = check_mdml(action_name) and return r
  template = default_template_name(action_name.to_s)
  if with_layout && !template_exempt_from_layout?(template) 
    render_with_layout(template, status)
  else
    render_without_layout(template, status)
  end
end

#render_file(template_path, status = nil, use_full_path = false, locals = {}) ⇒ Object

original version of method in actionpack 1.12.5 def render_file(template_path, status = nil, use_full_path = false, locals = {}) #:nodoc:

add_variables_to_assigns
assert_existence_of_template_file(template_path) if use_full_path
logger.info("Rendering #{template_path}" + (status ? " (#{status})" : '')) if logger
render_text(@template.render_file(template_path, use_full_path, locals), status)

end



15
16
17
18
19
20
21
# File 'lib/base.rb', line 15

def render_file(template_path, status = nil, use_full_path = false, locals = {}) #:nodoc:
  add_variables_to_assigns
  r = check_mdml and return r
  assert_existence_of_template_file(template_path) if use_full_path
  logger.info("Rendering #{template_path}" + (status ? " (#{status})" : '')) if logger
  render_text(@template.render_file(template_path, use_full_path, locals), status)
end

#view_classObject



52
53
54
55
56
57
58
59
60
61
62
# File 'lib/base.rb', line 52

def view_class
  # set to false if missing
  return nil if @view_class == false
  require_dependency "views/#{self.class.controller_name}/view"
  view_classname = "#{self.class.controller_class_name.to_s[0...-10]}View"
  if Module.constants.include?(view_classname)
    @view_class = eval(view_classname)
  else
    @view_class = false
  end
end