Module: TemplatesFor::ActionView

Defined in:
lib/templates_for/action_view.rb

Instance Method Summary collapse

Instance Method Details

#parse_templatesObject



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

def parse_templates
   'script', { :type => 'text/javascript' }, false do
    "\n  var JST = {};\n" + controller.templates_for_action.map do |template|
      "  JST['#{template}'] = document.getElementById('#{template}_template').innerHTML;"
    end.join("\n") + "\n"
  end
end

#render_templatesObject



7
8
9
10
11
12
13
# File 'lib/templates_for/action_view.rb', line 7

def render_templates
  controller.templates_for_action.map do |template|
     'script', { :type => 'text/template', :id => "#{template}_template" }, false do
      raw("\n" + render(template).gsub(/<!--(.*?)-->/, '').strip + "\n")
    end
  end.join("\n")
end

#templates_for_viewObject



3
4
5
# File 'lib/templates_for/action_view.rb', line 3

def templates_for_view
  raw(render_templates + "\n" + parse_templates)
end