Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Transformer: Remove empty elements

Pavel Shpak edited this page · 3 revisions

This transformer will remove any element that doesn't contain any other nodes or non-whitespace text.

lambda {|env|
  node = env[:node]
  return unless node.elem?

  unless node.children.any?{|c| !c.text? || c.content.strip.length > 0 }
    node.unlink
  end
}
Something went wrong with that request. Please try again.