temple 0.3.5 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +1 -2
- data/CHANGES +5 -1
- data/lib/temple.rb +35 -32
- data/lib/temple/html/attribute_merger.rb +2 -32
- data/lib/temple/html/attribute_remover.rb +28 -0
- data/lib/temple/html/attribute_sorter.rb +17 -0
- data/lib/temple/mixins/engine_dsl.rb +9 -7
- data/lib/temple/utils.rb +13 -0
- data/lib/temple/version.rb +1 -1
- data/test/html/test_attribute_merger.rb +22 -50
- data/test/html/test_attribute_remover.rb +44 -0
- data/test/html/test_attribute_sorter.rb +48 -0
- data/test/test_engine.rb +5 -2
- metadata +51 -54
data/.travis.yml
CHANGED
data/CHANGES
CHANGED
data/lib/temple.rb
CHANGED
@@ -1,48 +1,51 @@
|
|
1
1
|
require 'temple/version'
|
2
2
|
|
3
3
|
module Temple
|
4
|
-
autoload :InvalidExpression,
|
5
|
-
autoload :Generator,
|
6
|
-
autoload :Generators,
|
7
|
-
autoload :Engine,
|
8
|
-
autoload :Utils,
|
9
|
-
autoload :Filter,
|
10
|
-
autoload :Templates,
|
11
|
-
autoload :Grammar,
|
12
|
-
autoload :ImmutableHash,
|
13
|
-
autoload :MutableHash,
|
4
|
+
autoload :InvalidExpression, 'temple/generators'
|
5
|
+
autoload :Generator, 'temple/generators'
|
6
|
+
autoload :Generators, 'temple/generators'
|
7
|
+
autoload :Engine, 'temple/engine'
|
8
|
+
autoload :Utils, 'temple/utils'
|
9
|
+
autoload :Filter, 'temple/filter'
|
10
|
+
autoload :Templates, 'temple/templates'
|
11
|
+
autoload :Grammar, 'temple/grammar'
|
12
|
+
autoload :ImmutableHash, 'temple/hash'
|
13
|
+
autoload :MutableHash, 'temple/hash'
|
14
14
|
|
15
15
|
module Mixins
|
16
|
-
autoload :Dispatcher,
|
17
|
-
autoload :
|
18
|
-
autoload :
|
19
|
-
autoload :
|
20
|
-
autoload :
|
21
|
-
autoload :
|
16
|
+
autoload :Dispatcher, 'temple/mixins/dispatcher'
|
17
|
+
autoload :CompiledDispatcher, 'temple/mixins/dispatcher'
|
18
|
+
autoload :EngineDSL, 'temple/mixins/engine_dsl'
|
19
|
+
autoload :GrammarDSL, 'temple/mixins/grammar_dsl'
|
20
|
+
autoload :Options, 'temple/mixins/options'
|
21
|
+
autoload :DefaultOptions, 'temple/mixins/options'
|
22
|
+
autoload :Template, 'temple/mixins/template'
|
22
23
|
end
|
23
24
|
|
24
25
|
module ERB
|
25
|
-
autoload :Engine,
|
26
|
-
autoload :Parser,
|
27
|
-
autoload :Trimming,
|
28
|
-
autoload :Template,
|
26
|
+
autoload :Engine, 'temple/erb/engine'
|
27
|
+
autoload :Parser, 'temple/erb/parser'
|
28
|
+
autoload :Trimming, 'temple/erb/trimming'
|
29
|
+
autoload :Template, 'temple/erb/template'
|
29
30
|
end
|
30
31
|
|
31
32
|
module Filters
|
32
|
-
autoload :ControlFlow,
|
33
|
-
autoload :MultiFlattener,
|
34
|
-
autoload :StaticMerger,
|
35
|
-
autoload :DynamicInliner,
|
36
|
-
autoload :Escapable,
|
37
|
-
autoload :Eraser,
|
38
|
-
autoload :Validator,
|
33
|
+
autoload :ControlFlow, 'temple/filters/control_flow'
|
34
|
+
autoload :MultiFlattener, 'temple/filters/multi_flattener'
|
35
|
+
autoload :StaticMerger, 'temple/filters/static_merger'
|
36
|
+
autoload :DynamicInliner, 'temple/filters/dynamic_inliner'
|
37
|
+
autoload :Escapable, 'temple/filters/escapable'
|
38
|
+
autoload :Eraser, 'temple/filters/eraser'
|
39
|
+
autoload :Validator, 'temple/filters/validator'
|
39
40
|
end
|
40
41
|
|
41
42
|
module HTML
|
42
|
-
autoload :Dispatcher,
|
43
|
-
autoload :Filter,
|
44
|
-
autoload :Fast,
|
45
|
-
autoload :Pretty,
|
46
|
-
autoload :AttributeMerger,
|
43
|
+
autoload :Dispatcher, 'temple/html/dispatcher'
|
44
|
+
autoload :Filter, 'temple/html/filter'
|
45
|
+
autoload :Fast, 'temple/html/fast'
|
46
|
+
autoload :Pretty, 'temple/html/pretty'
|
47
|
+
autoload :AttributeMerger, 'temple/html/attribute_merger'
|
48
|
+
autoload :AttributeSorter, 'temple/html/attribute_sorter'
|
49
|
+
autoload :AttributeRemover, 'temple/html/attribute_remover'
|
47
50
|
end
|
48
51
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module Temple
|
2
2
|
module HTML
|
3
|
+
# This filter merges html attributes (e.g. used for id and class)
|
3
4
|
# @api public
|
4
5
|
class AttributeMerger < Filter
|
5
6
|
default_options[:attr_delimiter] = {'id' => '_', 'class' => ' '}
|
6
|
-
default_options[:sort_attrs] = true
|
7
7
|
|
8
8
|
def on_html_attrs(*attrs)
|
9
9
|
names = []
|
@@ -41,37 +41,7 @@ module Temple
|
|
41
41
|
names << name
|
42
42
|
end
|
43
43
|
end
|
44
|
-
|
45
|
-
[:multi, *result.map {|name,attr| compile(attr) }]
|
46
|
-
end
|
47
|
-
|
48
|
-
def on_html_attr(name, value)
|
49
|
-
if empty_exp?(value)
|
50
|
-
value
|
51
|
-
elsif contains_static?(value)
|
52
|
-
[:html, :attr, name, value]
|
53
|
-
else
|
54
|
-
tmp = unique_name
|
55
|
-
[:multi,
|
56
|
-
[:capture, tmp, compile(value)],
|
57
|
-
[:if, "!#{tmp}.empty?",
|
58
|
-
[:html, :attr, name, [:dynamic, tmp]]]]
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
protected
|
63
|
-
|
64
|
-
def contains_static?(exp)
|
65
|
-
case exp[0]
|
66
|
-
when :multi
|
67
|
-
exp[1..-1].any? {|e| contains_static?(e) }
|
68
|
-
when :escape
|
69
|
-
contains_static?(exp[2])
|
70
|
-
when :static
|
71
|
-
true
|
72
|
-
else
|
73
|
-
false
|
74
|
-
end
|
44
|
+
[:html, :attrs, *names.map {|name| result[name] }]
|
75
45
|
end
|
76
46
|
end
|
77
47
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Temple
|
2
|
+
module HTML
|
3
|
+
# This filter removes empty attributes
|
4
|
+
# @api public
|
5
|
+
class AttributeRemover < Filter
|
6
|
+
default_options[:remove_empty_attrs] = true
|
7
|
+
|
8
|
+
def on_html_attrs(*attrs)
|
9
|
+
[:multi, *(options[:remove_empty_attrs] ?
|
10
|
+
attrs.map {|attr| compile(attr) } : attrs)]
|
11
|
+
end
|
12
|
+
|
13
|
+
def on_html_attr(name, value)
|
14
|
+
if empty_exp?(value)
|
15
|
+
value
|
16
|
+
elsif contains_static?(value)
|
17
|
+
[:html, :attr, name, value]
|
18
|
+
else
|
19
|
+
tmp = unique_name
|
20
|
+
[:multi,
|
21
|
+
[:capture, tmp, compile(value)],
|
22
|
+
[:if, "!#{tmp}.empty?",
|
23
|
+
[:html, :attr, name, [:dynamic, tmp]]]]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Temple
|
2
|
+
module HTML
|
3
|
+
# This filter sorts html attributes.
|
4
|
+
# @api public
|
5
|
+
class AttributeSorter < Filter
|
6
|
+
default_options[:sort_attrs] = true
|
7
|
+
|
8
|
+
def on_html_attrs(*attrs)
|
9
|
+
attrs = attrs.sort_by do |attr|
|
10
|
+
raise(InvalidExpression, 'Attribute is not a html attr') if attr[0] != :html || attr[1] != :attr
|
11
|
+
attr[2].to_s
|
12
|
+
end if options[:sort_attrs]
|
13
|
+
[:html, :attrs, *attrs]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -88,12 +88,13 @@ module Temple
|
|
88
88
|
chain_modified!
|
89
89
|
end
|
90
90
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
91
|
+
# Shortcuts to access namespaces
|
92
|
+
{ :filter => Temple::Filters,
|
93
|
+
:generator => Temple::Generators,
|
94
|
+
:html => Temple::HTML }.each do |method, mod|
|
95
|
+
define_method(method) do |name, *options|
|
96
|
+
use(name, mod.const_get(name), *options)
|
97
|
+
end
|
97
98
|
end
|
98
99
|
|
99
100
|
private
|
@@ -113,8 +114,9 @@ module Temple
|
|
113
114
|
if Class === name
|
114
115
|
filter = name
|
115
116
|
name = filter.name.to_sym
|
117
|
+
else
|
118
|
+
raise(ArgumentError, 'First argument must be Class or Symbol') unless Symbol === name
|
116
119
|
end
|
117
|
-
raise(ArgumentError, 'First argument must be Class or Symbol') unless Symbol === name
|
118
120
|
|
119
121
|
if block
|
120
122
|
raise(ArgumentError, 'Class and block argument are not allowed at the same time') if filter
|
data/lib/temple/utils.rb
CHANGED
@@ -58,6 +58,19 @@ module Temple
|
|
58
58
|
"_#{prefix}#{@unique_name += 1}"
|
59
59
|
end
|
60
60
|
|
61
|
+
def contains_static?(exp)
|
62
|
+
case exp[0]
|
63
|
+
when :multi
|
64
|
+
exp[1..-1].any? {|e| contains_static?(e) }
|
65
|
+
when :escape
|
66
|
+
contains_static?(exp[2])
|
67
|
+
when :static
|
68
|
+
true
|
69
|
+
else
|
70
|
+
false
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
61
74
|
# Check if expression is empty
|
62
75
|
#
|
63
76
|
# @param exp [Array] Temple expression
|
data/lib/temple/version.rb
CHANGED
@@ -3,7 +3,6 @@ require 'helper'
|
|
3
3
|
describe Temple::HTML::AttributeMerger do
|
4
4
|
before do
|
5
5
|
@merger = Temple::HTML::AttributeMerger.new
|
6
|
-
@ordered_merger = Temple::HTML::AttributeMerger.new :sort_attrs => false
|
7
6
|
end
|
8
7
|
|
9
8
|
it 'should pass static attributes through' do
|
@@ -12,12 +11,12 @@ describe Temple::HTML::AttributeMerger do
|
|
12
11
|
[:html, :attrs, [:html, :attr, 'class', [:static, 'b']]],
|
13
12
|
[:content]
|
14
13
|
]).should.equal [:html, :tag, "div",
|
15
|
-
[:
|
14
|
+
[:html, :attrs,
|
16
15
|
[:html, :attr, "class", [:static, "b"]]],
|
17
16
|
[:content]]
|
18
17
|
end
|
19
18
|
|
20
|
-
it 'should
|
19
|
+
it 'should preserve the order of html attributes' do
|
21
20
|
@merger.call([:html, :tag,
|
22
21
|
'meta',
|
23
22
|
[:html, :attrs, [:html, :attr, 'c', [:static, '1']],
|
@@ -25,69 +24,39 @@ describe Temple::HTML::AttributeMerger do
|
|
25
24
|
[:html, :attr, 'a', [:static, '3']],
|
26
25
|
[:html, :attr, 'b', [:static, '4']]]
|
27
26
|
]).should.equal [:html, :tag, 'meta',
|
28
|
-
[:
|
29
|
-
[:html, :attr, 'a', [:static, '3']],
|
30
|
-
[:html, :attr, 'b', [:static, '4']],
|
31
|
-
[:html, :attr, 'c', [:static, '1']],
|
32
|
-
[:html, :attr, 'd', [:static, '2']]]]
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'should preserve the order of html attributes when :sort_attrs is false' do
|
36
|
-
@ordered_merger.call([:html, :tag,
|
37
|
-
'meta',
|
38
|
-
[:html, :attrs, [:html, :attr, 'c', [:static, '1']],
|
39
|
-
[:html, :attr, 'd', [:static, '2']],
|
40
|
-
[:html, :attr, 'a', [:static, '3']],
|
41
|
-
[:html, :attr, 'b', [:static, '4']]]
|
42
|
-
]).should.equal [:html, :tag, 'meta',
|
43
|
-
[:multi,
|
27
|
+
[:html, :attrs,
|
44
28
|
[:html, :attr, 'c', [:static, '1']],
|
45
29
|
[:html, :attr, 'd', [:static, '2']],
|
46
30
|
[:html, :attr, 'a', [:static, '3']],
|
47
31
|
[:html, :attr, 'b', [:static, '4']]]]
|
48
32
|
|
49
33
|
# Use case:
|
50
|
-
@
|
34
|
+
@merger.call([:html, :tag,
|
51
35
|
'meta',
|
52
36
|
[:html, :attrs, [:html, :attr, 'http-equiv', [:static, 'Content-Type']],
|
53
37
|
[:html, :attr, 'content', [:static, '']]]
|
54
38
|
]).should.equal [:html, :tag, 'meta',
|
55
|
-
[:
|
39
|
+
[:html, :attrs,
|
56
40
|
[:html, :attr, 'http-equiv', [:static, 'Content-Type']],
|
57
41
|
[:html, :attr, 'content', [:static, '']]]]
|
58
42
|
end
|
59
43
|
|
60
|
-
it 'should check for empty dynamic attribute' do
|
61
|
-
@merger.call([:html, :tag,
|
62
|
-
'div',
|
63
|
-
[:html, :attrs, [:html, :attr, 'class', [:dynamic, 'b']]],
|
64
|
-
[:content]
|
65
|
-
]).should.equal [:html, :tag, "div",
|
66
|
-
[:multi,
|
67
|
-
[:multi,
|
68
|
-
[:capture, "_temple_html_attributemerger1", [:dynamic, "b"]],
|
69
|
-
[:if, "!_temple_html_attributemerger1.empty?",
|
70
|
-
[:html, :attr, "class", [:dynamic, "_temple_html_attributemerger1"]]]]],
|
71
|
-
[:content]]
|
72
|
-
end
|
73
|
-
|
74
44
|
it 'should merge ids' do
|
75
45
|
@merger.call([:html, :tag,
|
76
46
|
'div',
|
77
47
|
[:html, :attrs, [:html, :attr, 'id', [:dynamic, 'a']], [:html, :attr, 'id', [:dynamic, 'b']]],
|
78
48
|
[:content]
|
79
49
|
]).should.equal [:html, :tag, "div",
|
80
|
-
[:
|
81
|
-
[:
|
82
|
-
[:
|
83
|
-
[:
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
[:html, :attr, "id", [:dynamic, "_temple_html_attributemerger2"]]]]],
|
50
|
+
[:html, :attrs,
|
51
|
+
[:html, :attr, "id",
|
52
|
+
[:multi,
|
53
|
+
[:dynamic, "a"],
|
54
|
+
[:capture, "_temple_html_attributemerger1",
|
55
|
+
[:dynamic, "b"]],
|
56
|
+
[:if, "!_temple_html_attributemerger1.empty?",
|
57
|
+
[:multi,
|
58
|
+
[:static, "_"],
|
59
|
+
[:dynamic, "_temple_html_attributemerger1"]]]]]],
|
91
60
|
[:content]]
|
92
61
|
end
|
93
62
|
|
@@ -97,12 +66,15 @@ describe Temple::HTML::AttributeMerger do
|
|
97
66
|
[:html, :attrs, [:html, :attr, 'class', [:static, 'a']], [:html, :attr, 'class', [:dynamic, 'b']]],
|
98
67
|
[:content]
|
99
68
|
]).should.equal [:html, :tag, "div",
|
100
|
-
[:
|
69
|
+
[:html, :attrs,
|
101
70
|
[:html, :attr, "class",
|
102
|
-
[:multi,
|
103
|
-
[:
|
71
|
+
[:multi,
|
72
|
+
[:static, "a"],
|
73
|
+
[:capture, "_temple_html_attributemerger1",
|
74
|
+
[:dynamic, "b"]],
|
104
75
|
[:if, "!_temple_html_attributemerger1.empty?",
|
105
|
-
[:multi,
|
76
|
+
[:multi,
|
77
|
+
[:static, " "],
|
106
78
|
[:dynamic, "_temple_html_attributemerger1"]]]]]],
|
107
79
|
[:content]]
|
108
80
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Temple::HTML::AttributeRemover do
|
4
|
+
before do
|
5
|
+
@remover = Temple::HTML::AttributeRemover.new
|
6
|
+
@disabled_remover = Temple::HTML::AttributeRemover.new :remove_empty_attrs => false
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should pass static attributes through' do
|
10
|
+
@remover.call([:html, :tag,
|
11
|
+
'div',
|
12
|
+
[:html, :attrs, [:html, :attr, 'class', [:static, 'b']]],
|
13
|
+
[:content]
|
14
|
+
]).should.equal [:html, :tag, "div",
|
15
|
+
[:multi,
|
16
|
+
[:html, :attr, "class", [:static, "b"]]],
|
17
|
+
[:content]]
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should check for empty dynamic attribute if :remove_empty_attrs is true' do
|
21
|
+
@remover.call([:html, :tag,
|
22
|
+
'div',
|
23
|
+
[:html, :attrs, [:html, :attr, 'class', [:dynamic, 'b']]],
|
24
|
+
[:content]
|
25
|
+
]).should.equal [:html, :tag, "div",
|
26
|
+
[:multi,
|
27
|
+
[:multi,
|
28
|
+
[:capture, "_temple_html_attributeremover1", [:dynamic, "b"]],
|
29
|
+
[:if, "!_temple_html_attributeremover1.empty?",
|
30
|
+
[:html, :attr, "class", [:dynamic, "_temple_html_attributeremover1"]]]]],
|
31
|
+
[:content]]
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should not check for empty dynamic attribute if :remove_empty_attrs is false' do
|
35
|
+
@disabled_remover.call([:html, :tag,
|
36
|
+
'div',
|
37
|
+
[:html, :attrs, [:html, :attr, 'class', [:dynamic, 'b']]],
|
38
|
+
[:content]
|
39
|
+
]).should.equal [:html, :tag, "div",
|
40
|
+
[:multi,
|
41
|
+
[:html, :attr, "class", [:dynamic, "b"]]],
|
42
|
+
[:content]]
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Temple::HTML::AttributeSorter do
|
4
|
+
before do
|
5
|
+
@ordered = Temple::HTML::AttributeSorter.new
|
6
|
+
@unordered = Temple::HTML::AttributeSorter.new :sort_attrs => false
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should sort html attributes by name by default, when :sort_attrs is true' do
|
10
|
+
@ordered.call([:html, :tag,
|
11
|
+
'meta',
|
12
|
+
[:html, :attrs, [:html, :attr, 'c', [:static, '1']],
|
13
|
+
[:html, :attr, 'd', [:static, '2']],
|
14
|
+
[:html, :attr, 'a', [:static, '3']],
|
15
|
+
[:html, :attr, 'b', [:static, '4']]]
|
16
|
+
]).should.equal [:html, :tag, 'meta',
|
17
|
+
[:html, :attrs,
|
18
|
+
[:html, :attr, 'a', [:static, '3']],
|
19
|
+
[:html, :attr, 'b', [:static, '4']],
|
20
|
+
[:html, :attr, 'c', [:static, '1']],
|
21
|
+
[:html, :attr, 'd', [:static, '2']]]]
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should preserve the order of html attributes when :sort_attrs is false' do
|
25
|
+
@unordered.call([:html, :tag,
|
26
|
+
'meta',
|
27
|
+
[:html, :attrs, [:html, :attr, 'c', [:static, '1']],
|
28
|
+
[:html, :attr, 'd', [:static, '2']],
|
29
|
+
[:html, :attr, 'a', [:static, '3']],
|
30
|
+
[:html, :attr, 'b', [:static, '4']]]
|
31
|
+
]).should.equal [:html, :tag, 'meta',
|
32
|
+
[:html, :attrs,
|
33
|
+
[:html, :attr, 'c', [:static, '1']],
|
34
|
+
[:html, :attr, 'd', [:static, '2']],
|
35
|
+
[:html, :attr, 'a', [:static, '3']],
|
36
|
+
[:html, :attr, 'b', [:static, '4']]]]
|
37
|
+
|
38
|
+
# Use case:
|
39
|
+
@unordered.call([:html, :tag,
|
40
|
+
'meta',
|
41
|
+
[:html, :attrs, [:html, :attr, 'http-equiv', [:static, 'Content-Type']],
|
42
|
+
[:html, :attr, 'content', [:static, '']]]
|
43
|
+
]).should.equal [:html, :tag, 'meta',
|
44
|
+
[:html, :attrs,
|
45
|
+
[:html, :attr, 'http-equiv', [:static, 'Content-Type']],
|
46
|
+
[:html, :attr, 'content', [:static, '']]]]
|
47
|
+
end
|
48
|
+
end
|
data/test/test_engine.rb
CHANGED
@@ -118,6 +118,7 @@ describe Temple::Engine do
|
|
118
118
|
engine.after :Parser, :MyFilter0 do |exp|
|
119
119
|
exp
|
120
120
|
end
|
121
|
+
TestEngine.chain.size.should.equal 8
|
121
122
|
engine.chain.size.should.equal 9
|
122
123
|
engine.chain[0].first.should.equal :Parser
|
123
124
|
engine.chain[1].first.should.equal :MyFilter0
|
@@ -129,6 +130,7 @@ describe Temple::Engine do
|
|
129
130
|
engine.before :MyFilter1, :MyFilter0 do |exp|
|
130
131
|
exp
|
131
132
|
end
|
133
|
+
TestEngine.chain.size.should.equal 8
|
132
134
|
engine.chain.size.should.equal 9
|
133
135
|
engine.chain[0].first.should.equal :Parser
|
134
136
|
engine.chain[1].first.should.equal :MyFilter0
|
@@ -138,6 +140,7 @@ describe Temple::Engine do
|
|
138
140
|
it 'should have #remove' do
|
139
141
|
engine = TestEngine.new
|
140
142
|
engine.remove :MyFilter1
|
143
|
+
TestEngine.chain.size.should.equal 8
|
141
144
|
engine.chain.size.should.equal 7
|
142
145
|
engine.chain[0].first.should.equal :Parser
|
143
146
|
engine.chain[1].first.should.equal :MyFilter2
|
@@ -145,10 +148,10 @@ describe Temple::Engine do
|
|
145
148
|
|
146
149
|
it 'should have #replace' do
|
147
150
|
engine = TestEngine.new
|
148
|
-
engine.
|
151
|
+
engine.replace :Parser, :MyParser do |exp|
|
149
152
|
exp
|
150
153
|
end
|
151
|
-
engine.chain.size.should.equal
|
154
|
+
engine.chain.size.should.equal 8
|
152
155
|
engine.chain[0].first.should.equal :MyParser
|
153
156
|
end
|
154
157
|
|
metadata
CHANGED
@@ -1,63 +1,58 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: temple
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.0
|
4
5
|
prerelease:
|
5
|
-
version: 0.3.5
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Magnus Holm
|
9
9
|
- Daniel Mendler
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
dependencies:
|
17
|
-
- !ruby/object:Gem::Dependency
|
13
|
+
date: 2012-02-26 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
18
16
|
name: tilt
|
19
|
-
|
20
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
17
|
+
requirement: &18003800 !ruby/object:Gem::Requirement
|
21
18
|
none: false
|
22
|
-
requirements:
|
23
|
-
- -
|
24
|
-
- !ruby/object:Gem::Version
|
25
|
-
version:
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
26
23
|
type: :development
|
27
|
-
version_requirements: *id001
|
28
|
-
- !ruby/object:Gem::Dependency
|
29
|
-
name: bacon
|
30
24
|
prerelease: false
|
31
|
-
|
25
|
+
version_requirements: *18003800
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: bacon
|
28
|
+
requirement: &18002180 !ruby/object:Gem::Requirement
|
32
29
|
none: false
|
33
|
-
requirements:
|
34
|
-
- -
|
35
|
-
- !ruby/object:Gem::Version
|
36
|
-
version:
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
37
34
|
type: :development
|
38
|
-
version_requirements: *id002
|
39
|
-
- !ruby/object:Gem::Dependency
|
40
|
-
name: rake
|
41
35
|
prerelease: false
|
42
|
-
|
36
|
+
version_requirements: *18002180
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: rake
|
39
|
+
requirement: &18000780 !ruby/object:Gem::Requirement
|
43
40
|
none: false
|
44
|
-
requirements:
|
45
|
-
- -
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version:
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
48
45
|
type: :development
|
49
|
-
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *18000780
|
50
48
|
description:
|
51
|
-
email:
|
49
|
+
email:
|
52
50
|
- judofyr@gmail.com
|
53
51
|
- mail@daniel-mendler.de
|
54
52
|
executables: []
|
55
|
-
|
56
53
|
extensions: []
|
57
|
-
|
58
54
|
extra_rdoc_files: []
|
59
|
-
|
60
|
-
files:
|
55
|
+
files:
|
61
56
|
- .gitignore
|
62
57
|
- .travis.yml
|
63
58
|
- .yardopts
|
@@ -85,6 +80,8 @@ files:
|
|
85
80
|
- lib/temple/grammar.rb
|
86
81
|
- lib/temple/hash.rb
|
87
82
|
- lib/temple/html/attribute_merger.rb
|
83
|
+
- lib/temple/html/attribute_remover.rb
|
84
|
+
- lib/temple/html/attribute_sorter.rb
|
88
85
|
- lib/temple/html/dispatcher.rb
|
89
86
|
- lib/temple/html/fast.rb
|
90
87
|
- lib/temple/html/filter.rb
|
@@ -108,6 +105,8 @@ files:
|
|
108
105
|
- test/filters/test_static_merger.rb
|
109
106
|
- test/helper.rb
|
110
107
|
- test/html/test_attribute_merger.rb
|
108
|
+
- test/html/test_attribute_remover.rb
|
109
|
+
- test/html/test_attribute_sorter.rb
|
111
110
|
- test/html/test_fast.rb
|
112
111
|
- test/html/test_pretty.rb
|
113
112
|
- test/mixins/test_dispatcher.rb
|
@@ -119,35 +118,31 @@ files:
|
|
119
118
|
- test/test_grammar.rb
|
120
119
|
- test/test_hash.rb
|
121
120
|
- test/test_utils.rb
|
122
|
-
has_rdoc: true
|
123
121
|
homepage: http://dojo.rubyforge.org/
|
124
122
|
licenses: []
|
125
|
-
|
126
123
|
post_install_message:
|
127
124
|
rdoc_options: []
|
128
|
-
|
129
|
-
require_paths:
|
125
|
+
require_paths:
|
130
126
|
- lib
|
131
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
132
128
|
none: false
|
133
|
-
requirements:
|
134
|
-
- -
|
135
|
-
- !ruby/object:Gem::Version
|
136
|
-
version:
|
137
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ! '>='
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
134
|
none: false
|
139
|
-
requirements:
|
140
|
-
- -
|
141
|
-
- !ruby/object:Gem::Version
|
142
|
-
version:
|
135
|
+
requirements:
|
136
|
+
- - ! '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
143
139
|
requirements: []
|
144
|
-
|
145
140
|
rubyforge_project:
|
146
|
-
rubygems_version: 1.
|
141
|
+
rubygems_version: 1.8.15
|
147
142
|
signing_key:
|
148
143
|
specification_version: 3
|
149
144
|
summary: Template compilation framework in Ruby
|
150
|
-
test_files:
|
145
|
+
test_files:
|
151
146
|
- test/filters/test_control_flow.rb
|
152
147
|
- test/filters/test_dynamic_inliner.rb
|
153
148
|
- test/filters/test_eraser.rb
|
@@ -156,6 +151,8 @@ test_files:
|
|
156
151
|
- test/filters/test_static_merger.rb
|
157
152
|
- test/helper.rb
|
158
153
|
- test/html/test_attribute_merger.rb
|
154
|
+
- test/html/test_attribute_remover.rb
|
155
|
+
- test/html/test_attribute_sorter.rb
|
159
156
|
- test/html/test_fast.rb
|
160
157
|
- test/html/test_pretty.rb
|
161
158
|
- test/mixins/test_dispatcher.rb
|