module ThemeBandit::HTMLParser
Public Instance Methods
inject_link_nodes()
click to toggle source
# File lib/theme_bandit/parser/html.rb, line 64 def inject_link_nodes link_nodes.each do |node| document.search('head').first.add_child(node) end end
inject_script_nodes()
click to toggle source
# File lib/theme_bandit/parser/html.rb, line 70 def inject_script_nodes script_nodes.each do |node| document.search('head').first.add_child(node) end end
link_nodes()
click to toggle source
# File lib/theme_bandit/parser/html.rb, line 43 def link_nodes [].tap do |arr| local_link_names.each do |link_path| link = Nokogiri::XML::Node.new 'link', document link.set_attribute('rel', 'stylesheet') link.set_attribute('href', "#{link_path}") arr << link end end end
local_link_names()
click to toggle source
# File lib/theme_bandit/parser/html.rb, line 29 def local_link_names path = "#{Dir.pwd}/theme/public/css/" Dir.entries(path).map do |file_name| "#{path}#{file_name}" if file_name['css'] end.compact end
local_script_names()
click to toggle source
# File lib/theme_bandit/parser/html.rb, line 36 def local_script_names path = "#{Dir.pwd}/theme/public/js/" Dir.entries(path).map do |file_name| "#{path}#{file_name}" if file_name['js'] end.compact.sort end
script_nodes()
click to toggle source
# File lib/theme_bandit/parser/html.rb, line 54 def script_nodes [].tap do |arr| local_script_names.each do |script_path| script = Nokogiri::XML::Node.new 'script', document script.set_attribute('src', "#{script_path}") arr << script end end end