temple 0.7.5 → 0.7.6

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: 8f6f31642317254d92c0a4d5da0b1c4bdae68ba1
4
- data.tar.gz: 1a85a078db6b17eef39d085a7065663a8d0f178e
3
+ metadata.gz: 49450d407bc6ae1762271d1ece670cdb9913b787
4
+ data.tar.gz: 946bbd14856936cb2d7dbbb431ecc8a9df55f26a
5
5
  SHA512:
6
- metadata.gz: 4206dc4b58672d35c58bc979d115aa7a34ec411115e9997e55be8a042c37245f2db835aa8ea5b99990964158af1728d4636aab24e3098b4fd7cd58d63554d5d2
7
- data.tar.gz: ccd399bd6cf7d05503afe1c5d1b028b31265cb2151c6d57f668c0788a2b7ded56bd0dc98a949f0884703e3df507e2573735a407de3c6acd149c961570fe06022
6
+ metadata.gz: 26a6a8e828240ea1293548173b2816b4378fce9f1609b946c48317652b02c2eb3e29aec99570e313de2a2155cab975cdc135c3529a209be693f6a9e8279ce97a
7
+ data.tar.gz: 542489791fab203a48b9810def3718e6416c00be2aa0a86587f4234b4f8d292977e29b4322b709ed2d9164ed1d21c71900c1feb58863a6c74952688622a7a954
@@ -1,4 +1,5 @@
1
1
  language: ruby
2
+
2
3
  rvm:
3
4
  - 1.9.3
4
5
  - 2.0.0
@@ -6,6 +7,9 @@ rvm:
6
7
  - ruby-head
7
8
  - jruby-19mode
8
9
  - rbx-2
10
+
11
+ sudo: false
12
+
9
13
  matrix:
10
14
  allow_failures:
11
15
  - rvm: ruby-head
data/CHANGES CHANGED
@@ -1,3 +1,7 @@
1
+ 0.7.6
2
+
3
+ * EngineDSL - add support for use(:Filter) { FilterClassName }
4
+
1
5
  0.7.5
2
6
 
3
7
  * HTML::Pretty Fix indentation issue (https://github.com/slim-template/slim-rails/issues/78)
@@ -188,7 +188,7 @@ The HTML abstraction is processed by the html filters (Temple::HTML::Fast and Te
188
188
  Example:
189
189
  [:html, :doctype, '5']
190
190
  generates
191
- <!DOCTYPE html5>
191
+ <!DOCTYPE html>
192
192
 
193
193
  Supported doctypes:
194
194
 
data/README.md CHANGED
@@ -23,6 +23,7 @@ Links
23
23
  * API documentation:
24
24
  * Latest Gem: <http://rubydoc.info/gems/temple/frames>
25
25
  * GitHub master: <http://rubydoc.info/github/judofyr/temple/master/frames>
26
+ * Abstractions: <http://github.com/judofyr/temple/blob/master/EXPRESSIONS.md>
26
27
 
27
28
  Overview
28
29
  --------
@@ -123,7 +124,7 @@ continue to use the HTML abstraction. Maybe you even want to write your
123
124
  compiler in another language? Sexps are easily serialized and if you don't
124
125
  mind working across processes, it's not a problem at all.
125
126
 
126
- All abstractions used by Temple are documented in {file:EXPRESSIONS.md EXPRESSIONS}.
127
+ All abstractions used by Temple are documented in [EXPRESSIONS.md](EXPRESSIONS.md).
127
128
 
128
129
  Compilers
129
130
  ---------
@@ -246,10 +247,13 @@ as following:
246
247
  Engines using Temple
247
248
  --------------------
248
249
 
249
- * [Slim](http://github.com/slim-template/slim)
250
- * [Sal](http://github.com/stonean/sal.rb)
250
+ * [Slim](https://github.com/slim-template/slim)
251
+ * [Hamlit](https://github.com/k0kubun/hamlit)
252
+ * [Faml](https://github.com/eagletmt/faml)
253
+ * [Sal](https://github.com/stonean/sal.rb)
251
254
  * [Temple-Mustache (Example implementation)](https://github.com/minad/temple-mustache)
252
255
  * Temple ERB example implementation (Temple::ERB::Template)
256
+ * [WLang](https://github.com/blambeau/wlang)
253
257
 
254
258
  Acknowledgements
255
259
  ----------------
@@ -86,7 +86,22 @@ module Temple
86
86
  method_name = "FILTER #{name}"
87
87
  c = Class === self ? self : singleton_class
88
88
  filter = c.class_eval { define_method(method_name, &filter); instance_method(method_name) }
89
- proc {|engine| filter.arity == 1 ? filter.bind(engine) : filter.bind(engine).call }
89
+ proc do |engine|
90
+ if filter.arity == 1
91
+ # the proc takes one argument, e.g. use(:Filter) {|exp| exp }
92
+ filter.bind(engine)
93
+ else
94
+ f = filter.bind(engine).call
95
+ if f.respond_to? :call
96
+ # the proc returns a callable object, e.g. use(:Filter) { Filter.new }
97
+ f
98
+ else
99
+ raise(ArgumentError, 'Proc or blocks must return a Callable or a Class') unless f.respond_to? :new
100
+ # the proc returns a class, e.g. use(:Filter) { Filter }
101
+ f.new(f.respond_to?(:options) ? engine.options.to_hash.select {|k,v| f.options.valid_key?(k) } : engine.options)
102
+ end
103
+ end
104
+ end
90
105
  end
91
106
 
92
107
  def chain_element(args, block)
@@ -1,3 +1,3 @@
1
1
  module Temple
2
- VERSION = '0.7.5'
2
+ VERSION = '0.7.6'
3
3
  end
@@ -13,6 +13,15 @@ class Callable2
13
13
  end
14
14
  end
15
15
 
16
+ class MySpecialFilter
17
+ def initialize(opts = {})
18
+ end
19
+
20
+ def call(exp)
21
+ exp
22
+ end
23
+ end
24
+
16
25
  class TestEngine < Temple::Engine
17
26
  use(:Parser) do |input|
18
27
  [:static, input]
@@ -22,13 +31,14 @@ class TestEngine < Temple::Engine
22
31
  use Temple::HTML::Pretty, pretty: true
23
32
  filter :MultiFlattener
24
33
  generator :ArrayBuffer
34
+ use(:BeforeBeforeLast) { MySpecialFilter }
25
35
  use :BeforeLast, Callable1.new
26
36
  use(:Last) { Callable2.new }
27
37
  end
28
38
 
29
39
  describe Temple::Engine do
30
40
  it 'should build chain' do
31
- TestEngine.chain.size.should.equal 8
41
+ TestEngine.chain.size.should.equal 9
32
42
 
33
43
  TestEngine.chain[0].first.should.equal :Parser
34
44
  TestEngine.chain[0].size.should.equal 2
@@ -54,13 +64,17 @@ describe Temple::Engine do
54
64
  TestEngine.chain[5].size.should.equal 2
55
65
  TestEngine.chain[5].last.should.be.instance_of Proc
56
66
 
57
- TestEngine.chain[6].first.should.equal :BeforeLast
67
+ TestEngine.chain[6].first.should.equal :BeforeBeforeLast
58
68
  TestEngine.chain[6].size.should.equal 2
59
69
  TestEngine.chain[6].last.should.be.instance_of Proc
60
70
 
61
- TestEngine.chain[7].first.should.equal :Last
71
+ TestEngine.chain[7].first.should.equal :BeforeLast
62
72
  TestEngine.chain[7].size.should.equal 2
63
73
  TestEngine.chain[7].last.should.be.instance_of Proc
74
+
75
+ TestEngine.chain[8].first.should.equal :Last
76
+ TestEngine.chain[8].size.should.equal 2
77
+ TestEngine.chain[8].last.should.be.instance_of Proc
64
78
  end
65
79
 
66
80
  it 'should instantiate chain' do
@@ -71,48 +85,49 @@ describe Temple::Engine do
71
85
  call_chain[3].should.be.instance_of Temple::HTML::Pretty
72
86
  call_chain[4].should.be.instance_of Temple::Filters::MultiFlattener
73
87
  call_chain[5].should.be.instance_of Temple::Generators::ArrayBuffer
74
- call_chain[6].should.be.instance_of Callable1
75
- call_chain[7].should.be.instance_of Callable2
88
+ call_chain[6].should.be.instance_of MySpecialFilter
89
+ call_chain[7].should.be.instance_of Callable1
90
+ call_chain[8].should.be.instance_of Callable2
76
91
  end
77
92
 
78
93
  it 'should have #append' do
79
94
  engine = TestEngine.new
80
95
  call_chain = engine.send(:call_chain)
81
- call_chain.size.should.equal 8
96
+ call_chain.size.should.equal 9
82
97
 
83
98
  engine.append :MyFilter3 do |exp|
84
99
  exp
85
100
  end
86
101
 
87
- TestEngine.chain.size.should.equal 8
88
- engine.chain.size.should.equal 9
89
- engine.chain[8].first.should.equal :MyFilter3
90
- engine.chain[8].size.should.equal 2
91
- engine.chain[8].last.should.be.instance_of Proc
102
+ TestEngine.chain.size.should.equal 9
103
+ engine.chain.size.should.equal 10
104
+ engine.chain[9].first.should.equal :MyFilter3
105
+ engine.chain[9].size.should.equal 2
106
+ engine.chain[9].last.should.be.instance_of Proc
92
107
 
93
108
  call_chain = engine.send(:call_chain)
94
- call_chain.size.should.equal 9
95
- call_chain[8].should.be.instance_of Method
109
+ call_chain.size.should.equal 10
110
+ call_chain[9].should.be.instance_of Method
96
111
  end
97
112
 
98
113
  it 'should have #prepend' do
99
114
  engine = TestEngine.new
100
115
  call_chain = engine.send(:call_chain)
101
- call_chain.size.should.equal 8
116
+ call_chain.size.should.equal 9
102
117
 
103
118
  engine.prepend :MyFilter0 do |exp|
104
119
  exp
105
120
  end
106
121
 
107
- TestEngine.chain.size.should.equal 8
108
- engine.chain.size.should.equal 9
122
+ TestEngine.chain.size.should.equal 9
123
+ engine.chain.size.should.equal 10
109
124
  engine.chain[0].first.should.equal :MyFilter0
110
125
  engine.chain[0].size.should.equal 2
111
126
  engine.chain[0].last.should.be.instance_of Proc
112
127
  engine.chain[1].first.should.equal :Parser
113
128
 
114
129
  call_chain = engine.send(:call_chain)
115
- call_chain.size.should.equal 9
130
+ call_chain.size.should.equal 10
116
131
  call_chain[0].should.be.instance_of Method
117
132
  end
118
133
 
@@ -121,8 +136,8 @@ describe Temple::Engine do
121
136
  engine.after :Parser, :MyFilter0 do |exp|
122
137
  exp
123
138
  end
124
- TestEngine.chain.size.should.equal 8
125
- engine.chain.size.should.equal 9
139
+ TestEngine.chain.size.should.equal 9
140
+ engine.chain.size.should.equal 10
126
141
  engine.chain[0].first.should.equal :Parser
127
142
  engine.chain[1].first.should.equal :MyFilter0
128
143
  engine.chain[2].first.should.equal :MyFilter1
@@ -133,8 +148,8 @@ describe Temple::Engine do
133
148
  engine.before :MyFilter1, :MyFilter0 do |exp|
134
149
  exp
135
150
  end
136
- TestEngine.chain.size.should.equal 8
137
- engine.chain.size.should.equal 9
151
+ TestEngine.chain.size.should.equal 9
152
+ engine.chain.size.should.equal 10
138
153
  engine.chain[0].first.should.equal :Parser
139
154
  engine.chain[1].first.should.equal :MyFilter0
140
155
  engine.chain[2].first.should.equal :MyFilter1
@@ -143,8 +158,8 @@ describe Temple::Engine do
143
158
  it 'should have #remove' do
144
159
  engine = TestEngine.new
145
160
  engine.remove :MyFilter1
146
- TestEngine.chain.size.should.equal 8
147
- engine.chain.size.should.equal 7
161
+ TestEngine.chain.size.should.equal 9
162
+ engine.chain.size.should.equal 8
148
163
  engine.chain[0].first.should.equal :Parser
149
164
  engine.chain[1].first.should.equal :MyFilter2
150
165
 
@@ -158,17 +173,17 @@ describe Temple::Engine do
158
173
  engine.replace :Parser, :MyParser do |exp|
159
174
  exp
160
175
  end
161
- engine.chain.size.should.equal 8
176
+ engine.chain.size.should.equal 9
162
177
  engine.chain[0].first.should.equal :MyParser
163
178
  end
164
179
 
165
180
  it 'should work with inheritance' do
166
181
  inherited_engine = Class.new(TestEngine)
167
- inherited_engine.chain.size.should.equal 8
182
+ inherited_engine.chain.size.should.equal 9
168
183
  inherited_engine.append :MyFilter3 do |exp|
169
184
  exp
170
185
  end
171
- inherited_engine.chain.size.should.equal 9
172
- TestEngine.chain.size.should.equal 8
186
+ inherited_engine.chain.size.should.equal 10
187
+ TestEngine.chain.size.should.equal 9
173
188
  end
174
189
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: temple
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.5
4
+ version: 0.7.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Magnus Holm
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-01-08 00:00:00.000000000 Z
12
+ date: 2015-06-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: tilt