-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Small refactoring: moved Nokogiri manipulations into a separate file
- Loading branch information
Alex Chaplinsky
committed
Aug 2, 2014
1 parent
e0deb80
commit 6cfc882
Showing
4 changed files
with
56 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
require "polymer-rails/version" | ||
require "polymer-rails/processors/directive_processor" | ||
require "polymer-rails/processors/assets_processor" | ||
require "polymer-rails/processors/components_processor" | ||
require "polymer-rails/helpers/asset_tag_helper" | ||
require "polymer-rails/engine" if defined?(::Rails) | ||
require "polymer-rails/railtie" if defined?(::Rails) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
module Polymer | ||
module Rails | ||
class Component | ||
|
||
def initialize(data) | ||
@doc = Nokogiri::HTML.fragment(data) | ||
end | ||
|
||
def create_node(name, content) | ||
node = Nokogiri::XML::Node.new(name, @doc) | ||
node.content = content | ||
node | ||
end | ||
|
||
def replace_node(node, name, content) | ||
node.replace create_node(name, content) | ||
end | ||
|
||
def stylesheets | ||
@doc.css("link[rel='stylesheet']") | ||
end | ||
|
||
def javascripts | ||
@doc.css("script[src]") | ||
end | ||
|
||
def imports | ||
@doc.css("link[rel='import']") | ||
end | ||
|
||
def stringify | ||
@doc.inner_html | ||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters