Module: CommentSearchers
- Included in:
- DomSection, DomTemplate
- Defined in:
- lib/volt/page/targets/helpers/comment_searchers.rb
Instance Method Summary collapse
-
#build_from_html(html) ⇒ Object
Returns an unattached div with the nodes from the passed in html.
- #find_by_comment(text, in_node = `document`) ⇒ Object
Instance Method Details
#build_from_html(html) ⇒ Object
Returns an unattached div with the nodes from the passed in html.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/volt/page/targets/helpers/comment_searchers.rb', line 15 def build_from_html(html) temp_div = nil %x{ temp_div = document.createElement('div'); var doc = jQuery.parseHTML(html); if (doc) { for (var i=0;i < doc.length;i++) { temp_div.appendChild(doc[i]); } } } return temp_div end |
#find_by_comment(text, in_node = `document`) ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'lib/volt/page/targets/helpers/comment_searchers.rb', line 3 def find_by_comment(text, in_node=`document`) node = nil %x{ node = document.evaluate("//comment()[. = ' " + text + " ']", in_node, null, XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null).iterateNext(); } return node end |