Sha256: e05d07ed4822b8fa69fd0144f7c386c0a371e3f98566df7f99b38aa25f93c0cc
Contents?: true
Size: 1019 Bytes
Versions: 4
Compression:
Stored size: 1019 Bytes
Contents
module Deface module TemplateHelper # used to find source for a partial or template using virutal_path def load_template_source(virtual_path, partial, include_overrides=true) parts = virtual_path.split("/") prefix = [] if parts.size == 2 prefix << "" name = virtual_path else prefix << parts.shift name = parts.join("/") end @lookup_context ||= ActionView::LookupContext.new(ActionController::Base.view_paths, {:formats => [:html]}) source = @lookup_context.find(name, prefix, partial).source if include_overrides Deface::Override.apply(source, {:virtual_path => virtual_path}, false) else source end end #gets source erb for an element def element_source(template_source, selector) doc = Deface::Parser.convert(template_source) doc.css(selector).inject([]) do |result, match| result << Deface::Parser.undo_erb_markup!(match.to_s.dup) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
deface-0.7.0 | lib/deface/template_helper.rb |
deface-0.6.1 | lib/deface/template_helper.rb |
deface-0.6.0 | lib/deface/template_helper.rb |
deface-0.5.7 | lib/deface/template_helper.rb |