lib/deface/template_helper.rb in deface-0.5.0 vs lib/deface/template_helper.rb in deface-0.5.1

- old
+ new

@@ -15,7 +15,16 @@ @lookup_context ||= ActionView::LookupContext.new(ActionController::Base.view_paths, {:formats => [:html]}) @lookup_context.find(name, prefix, partial).source 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