pakyow-presenter/lib/presenter/doc_helpers.rb in pakyow-presenter-0.8.0 vs pakyow-presenter/lib/presenter/doc_helpers.rb in pakyow-presenter-0.9.0

- old
+ new

@@ -1,77 +1,17 @@ module Pakyow module Presenter module DocHelpers - def breadth_first(doc) - queue = [doc] - until queue.empty? - node = queue.shift - catch(:reject) { - yield node - queue.concat(node.children) - } - end + def self.self_closing_tag?(tag) + %w[area base basefont br hr input img link meta].include? tag end - def path_to(child) - path = [] - - return path if child == @doc - - child.ancestors.each {|a| - # since ancestors goes all the way to doc root, stop when we get to the level of @doc - break if a.children.include?(@doc) - - path.unshift(a.children.index(child)) - child = a - } - - return path + def self.form_field?(tag) + %w[input select textarea button].include? tag end - def path_within_path?(child_path, parent_path) - parent_path.each_with_index {|pp_step, i| - return false unless pp_step == child_path[i] - } - - true - end - - def doc_from_path(path) - o = @doc - - # if path is empty we're at self - return o if path.empty? - - path.each {|i| - if child = o.children[i] - o = child - else - break - end - } - - return o - end - - def view_from_path(path) - view = View.from_doc(doc_from_path(path)) - view.related_views << self - - # workaround for nokogiri in jruby (see https://github.com/sparklemotion/nokogiri/issues/1060) - view.doc.document.errors = [] - - return view - end - - def to_html - @doc.to_html - end - - alias :to_s :to_html - - def ==(o) - self.class == o.class && self.to_html == o.to_html + def self.tag_without_value?(tag) + %w[select].include? tag end end end end