Sha256: 9c8d0ece596bcc1b006138543bac77b0eb1dd3cfebace08947ad60991bbb7f45
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 KB
Contents
module ActionView #:nodoc: module TemplateHandlers #:nodoc: class Erector < TemplateHandler include Compilable def self.line_offset 2 end ActionView::Template.instance_eval do register_template_handler :rb, ActionView::TemplateHandlers::Erector end def compile(template) relative_path_parts = template.path.split('/') is_partial = relative_path_parts.last =~ /^_/ require_dependency File.expand_path(template.filename) widget_class_parts = relative_path_parts.inject(['Views']) do |class_parts, node| class_parts << node.gsub(/^_/, "").gsub(/(\.html)?\.rb$/, '').classify class_parts end widget_class_name = widget_class_parts.join("::") render_method = is_partial ? 'render_partial' : 'render' erb_template = "<% #{widget_class_name}.new(self, controller.assigns, _erbout).#{render_method} %>" ::ERB.new(erb_template, nil, ActionView::Base.erb_trim_mode).src end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
erector-0.5.0 | lib/erector/rails/template_handlers/2.1.0/action_view_template_handler.rb |