README.markdown in deface-0.6.0 vs README.markdown in deface-0.6.1

- old
+ new

@@ -31,10 +31,12 @@ * <tt>:insert_top</tt> - Inserts inside all elements that match the supplied selector, as the first child. * <tt>:insert_bottom</tt> - Inserts inside all elements that match the supplied selector, as the last child. +* <tt>:set_attributes</tt> - Sets (or adds) attributes to all elements that match the supplied selector, expects :attributes option to be passed. + Source ------ * <tt>:text</tt> - String containing markup * <tt>:partial</tt> - Relative path to a partial @@ -55,10 +57,12 @@ * <tt>:sequence => {:before => "*override_name*"}</tt> - where "*override_name*" is the name of an override defined for the same virutal_path, the current override will be appplied before the named override passed. * <tt>:sequence => {:after => "*override_name*")</tt> - the current override will be applied after the named override passed. +* <tt>:attributes</tt> - A hash containing all the attributes to be set on the matched elements, eg: :attributes => {:class => "green", :title => "some string"} + Examples ======== Replaces all instances of _h1_ in the `posts/_form.html.erb` partial with `<h1>New Post</h1>` @@ -86,9 +90,15 @@ Deface::Override.new(:virtual_path => "posts/new", :name => "example-4", :remove => "code[erb-loud]:contains('helper_method')", :original => "<%= helper_method %>") +Sets (or adds if not present) the `class` and `title` attributes to all instances of `a` with an id of `link` in `posts/index.html.erb` + + Deface::Override.new(:virtual_path => 'posts/index', + :name => 'add_attrs_to_a_link', + :set_attributes => 'a#link', + :attributes => {:class => 'pretty', :title => 'This is a link'}) Implementation ============== Deface temporarily converts ERB files into a pseudo HTML markup that can be parsed and queired by Nokogiri, using the following approach: