dominate 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/dominate.gemspec +2 -0
- data/lib/dominate/dom.rb +18 -1
- data/lib/dominate/version.rb +1 -1
- data/lib/dominate.rb +1 -0
- data/test/dominate_test.rb +2 -0
- data/test/dummy/footer.slim +2 -0
- metadata +31 -3
- data/test/dummy/footer.html +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94e99ad536f854bdb002dc3616eedacb5181e478
|
4
|
+
data.tar.gz: 371127d9331c6c85ed5447868c00642d38e2dece
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15e58c2904a7c493f7195995cfac87e1cbcd590a088a2f33ec0801f4cc7a118de0d349a0def8221f621ca648d898b6812b420e0860cd541137d2e8abd36eb542
|
7
|
+
data.tar.gz: cd353c41c3c81b7698550e838dbffdf59b17acf432826911f72ce236de8e8ab101778886dd13cc3ab10993765c6fb20aef5034fccd6f356e21c33d888ae252d9
|
data/dominate.gemspec
CHANGED
@@ -19,10 +19,12 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_dependency "nokogiri"
|
22
|
+
spec.add_dependency "tilt"
|
22
23
|
|
23
24
|
spec.add_development_dependency "bundler", "~> 1.3"
|
24
25
|
spec.add_development_dependency "rake"
|
25
26
|
spec.add_development_dependency "cutest-cj"
|
26
27
|
spec.add_development_dependency "pry"
|
27
28
|
spec.add_development_dependency "awesome_print"
|
29
|
+
spec.add_development_dependency "slim"
|
28
30
|
end
|
data/lib/dominate/dom.rb
CHANGED
@@ -3,6 +3,7 @@ module Dominate
|
|
3
3
|
attr_accessor :raw_html, :instance, :doc
|
4
4
|
|
5
5
|
PARTIAL_REGEX = /<!--\s*@partial\s*([a-zA-Z0-9\-_]*)\s*-->/
|
6
|
+
VIEW_TYPES = %w(html slim haml erb)
|
6
7
|
|
7
8
|
def initialize raw_html, instance = false
|
8
9
|
@raw_html = raw_html
|
@@ -22,7 +23,7 @@ module Dominate
|
|
22
23
|
if match = e.to_html.strip.match(PARTIAL_REGEX)
|
23
24
|
partial = match[1]
|
24
25
|
e.swap Nokogiri::HTML.fragment(
|
25
|
-
|
26
|
+
load_view "#{view_path}/#{partial}"
|
26
27
|
)
|
27
28
|
end
|
28
29
|
end
|
@@ -54,5 +55,21 @@ module Dominate
|
|
54
55
|
def view_path
|
55
56
|
Dominate.config.view_path
|
56
57
|
end
|
58
|
+
|
59
|
+
def load_view path
|
60
|
+
html = false
|
61
|
+
|
62
|
+
VIEW_TYPES.each do |type|
|
63
|
+
file = "#{path}.#{type}"
|
64
|
+
|
65
|
+
if File.file? file
|
66
|
+
template = Tilt.new file
|
67
|
+
html = template.render
|
68
|
+
break
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
html
|
73
|
+
end
|
57
74
|
end
|
58
75
|
end
|
data/lib/dominate/version.rb
CHANGED
data/lib/dominate.rb
CHANGED
data/test/dominate_test.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dominate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- cj
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: tilt
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +108,20 @@ dependencies:
|
|
94
108
|
- - ">="
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: slim
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
97
125
|
description: Allows you to manipulate the dom without touching it.
|
98
126
|
email:
|
99
127
|
- cjlazell@gmail.com
|
@@ -113,7 +141,7 @@ files:
|
|
113
141
|
- lib/dominate/scope.rb
|
114
142
|
- lib/dominate/version.rb
|
115
143
|
- test/dominate_test.rb
|
116
|
-
- test/dummy/footer.
|
144
|
+
- test/dummy/footer.slim
|
117
145
|
- test/dummy/header.html
|
118
146
|
- test/dummy/index.html
|
119
147
|
- test/helper.rb
|
@@ -143,7 +171,7 @@ specification_version: 4
|
|
143
171
|
summary: Templating Engine.
|
144
172
|
test_files:
|
145
173
|
- test/dominate_test.rb
|
146
|
-
- test/dummy/footer.
|
174
|
+
- test/dummy/footer.slim
|
147
175
|
- test/dummy/header.html
|
148
176
|
- test/dummy/index.html
|
149
177
|
- test/helper.rb
|
data/test/dummy/footer.html
DELETED