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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6dfebc8c4d9a8b4820871cc1ead5f65be47e475b
4
- data.tar.gz: 015fc0939f8bd03b4a895a71fdeb4e1d0ae36d40
3
+ metadata.gz: 94e99ad536f854bdb002dc3616eedacb5181e478
4
+ data.tar.gz: 371127d9331c6c85ed5447868c00642d38e2dece
5
5
  SHA512:
6
- metadata.gz: f080d42f48dd437d9a9ed1f5884c6f829fb7fe85f5702d911872f83fe18523f5ca3b0c1973ea6c2b502a64f5e77ceab4db53050057c91a98563f65869a051cf5
7
- data.tar.gz: 30e238e4e39cea411892e2707032e61914e74928e78c8f049f0f481c8b224af8b55b7f5fb270323940d864ae718ae8c0fb4768cc73ecd2223d1660b99479f501
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
- File.read "#{view_path}/#{partial}.html"
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
@@ -1,3 +1,3 @@
1
1
  module Dominate
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/dominate.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "nokogiri"
2
+ require "tilt"
2
3
  require "dominate/version"
3
4
  require "dominate/inflectors"
4
5
  require "dominate/scope"
@@ -1,5 +1,7 @@
1
1
  require_relative 'helper'
2
2
  require 'dominate'
3
+ require 'slim'
4
+
3
5
  setup do
4
6
  Dominate.reset_config!
5
7
  Dominate.setup do |c|
@@ -0,0 +1,2 @@
1
+ #footer data-scope="footer"
2
+ span data-prop="company.name"
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.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.html
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.html
174
+ - test/dummy/footer.slim
147
175
  - test/dummy/header.html
148
176
  - test/dummy/index.html
149
177
  - test/helper.rb
@@ -1,3 +0,0 @@
1
- <div data-scope="footer">
2
- <span data-prop="company.name"></span>
3
- </div>