temple 0.6.8 → 0.6.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGES +12 -1
- data/lib/temple/generator.rb +7 -0
- data/lib/temple/hash.rb +2 -1
- data/lib/temple/html/pretty.rb +1 -1
- data/lib/temple/html/safe.rb +23 -0
- data/lib/temple/mixins/grammar_dsl.rb +8 -7
- data/lib/temple/templates/tilt.rb +2 -3
- data/lib/temple/utils.rb +3 -2
- data/lib/temple/version.rb +1 -1
- data/test/filters/test_escapable.rb +1 -1
- data/test/helper.rb +2 -11
- data/test/html/test_pretty.rb +2 -2
- metadata +17 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1bcc7e8bd7f61ec9c8e2f023f0fb53688b0df1c2
|
4
|
+
data.tar.gz: 6b409c3649bf823b1cf844c9604929ee51b42dab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3a07bb7ec8d123a48c659771f3c59d09e183519cefcb47b9fc7af5c869d77271da4773906652e97cf5d6c6b3b6b6d937641fcacd00a491a02fdfebbd33899c6
|
7
|
+
data.tar.gz: 5061b599c57d49d77f48bde5b89c8aac6b20df3038de15386f12913e2c7122f107af38500073fd76ff76c77001b55312fbd9629c447a3399a81a90121f1b3758
|
data/CHANGES
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
0.6.9
|
2
|
+
|
3
|
+
* HTML::Pretty: Fix wrong line numbers
|
4
|
+
* Tilt template: Don't overwrite buffer always
|
5
|
+
* Generator: add preamble and postamble which do nothing
|
6
|
+
* Tilt template: don't overwrite streaming option
|
7
|
+
* OptionHash: inherit valid keys
|
8
|
+
* temple/html/safe: add poor man's html_safe? implementation (not required automatically)
|
9
|
+
* Temple::Mixins::GrammarDSL - Add some missing match? methods
|
10
|
+
* Temple::Utils.escape_html_safe - Add parameter safe
|
11
|
+
|
1
12
|
0.6.8
|
2
13
|
|
3
14
|
* HTML::Fast add svg doctype
|
@@ -177,7 +188,7 @@
|
|
177
188
|
|
178
189
|
0.1.1
|
179
190
|
|
180
|
-
* Test added
|
191
|
+
* Test added
|
181
192
|
|
182
193
|
0.1.0
|
183
194
|
|
data/lib/temple/generator.rb
CHANGED
data/lib/temple/hash.rb
CHANGED
data/lib/temple/html/pretty.rb
CHANGED
@@ -39,7 +39,7 @@ module Temple
|
|
39
39
|
tmp = unique_name
|
40
40
|
indent_code = ''
|
41
41
|
indent_code << "#{tmp} = #{tmp}.sub(/\\A\\s*\\n?/, \"\\n\"); " if options[:indent_tags].include?(@last)
|
42
|
-
indent_code << "#{tmp} = #{tmp}.gsub(\"
|
42
|
+
indent_code << "#{tmp} = #{tmp}.gsub(\"\\n\", #{indent.inspect}); "
|
43
43
|
if ''.respond_to?(:html_safe)
|
44
44
|
safe = unique_name
|
45
45
|
# we have to first save if the string was html_safe
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Temple
|
2
|
+
module HTML
|
3
|
+
class SafeString < String
|
4
|
+
def html_safe?; true end
|
5
|
+
def html_safe; self end
|
6
|
+
def to_s; self end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class Object
|
12
|
+
def html_safe?; false end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Numeric
|
16
|
+
def html_safe?; true end
|
17
|
+
end
|
18
|
+
|
19
|
+
class String
|
20
|
+
def html_safe
|
21
|
+
Temple::HTML::SafeString.new(self)
|
22
|
+
end
|
23
|
+
end
|
@@ -7,6 +7,12 @@ module Temple
|
|
7
7
|
@grammar = grammar
|
8
8
|
end
|
9
9
|
|
10
|
+
def match?(exp)
|
11
|
+
match(exp, [])
|
12
|
+
end
|
13
|
+
alias === match?
|
14
|
+
alias =~ match?
|
15
|
+
|
10
16
|
def |(rule)
|
11
17
|
Or.new(@grammar, self, rule)
|
12
18
|
end
|
@@ -53,10 +59,6 @@ module Temple
|
|
53
59
|
success
|
54
60
|
end
|
55
61
|
|
56
|
-
def match?(exp)
|
57
|
-
match(exp, [])
|
58
|
-
end
|
59
|
-
|
60
62
|
def validate!(exp)
|
61
63
|
unmatched = []
|
62
64
|
unless match(exp, unmatched)
|
@@ -120,14 +122,13 @@ module Temple
|
|
120
122
|
def match?(exp)
|
121
123
|
const_get(:Expression).match?(exp)
|
122
124
|
end
|
125
|
+
alias === match?
|
126
|
+
alias =~ match?
|
123
127
|
|
124
128
|
def validate!(exp)
|
125
129
|
const_get(:Expression).validate!(exp)
|
126
130
|
end
|
127
131
|
|
128
|
-
alias === match?
|
129
|
-
alias =~ match?
|
130
|
-
|
131
132
|
def Value(value)
|
132
133
|
Value.new(self, value)
|
133
134
|
end
|
@@ -21,10 +21,9 @@ module Temple
|
|
21
21
|
#
|
22
22
|
# @return [void]
|
23
23
|
def prepare
|
24
|
-
|
25
|
-
opts = {}.update(self.class.default_options).update(options).update(:file => eval_file, :streaming => false)
|
24
|
+
opts = {}.update(self.class.default_options).update(options).update(:file => eval_file)
|
26
25
|
opts.delete(:mime_type)
|
27
|
-
opts.delete(:outvar) # Sinatra gives us
|
26
|
+
opts[:buffer] ||= opts.delete(:outvar) if opts.include?(:outvar) # HACK Sinatra gives us outvar instead of buffer
|
28
27
|
@src = self.class.compile(data, opts)
|
29
28
|
end
|
30
29
|
|
data/lib/temple/utils.rb
CHANGED
@@ -13,9 +13,10 @@ module Temple
|
|
13
13
|
# Strings which are declared as html_safe are not escaped.
|
14
14
|
#
|
15
15
|
# @param html [String] The string to escape
|
16
|
+
# @param safe [Boolean] If false use escape_html
|
16
17
|
# @return [String] The escaped string
|
17
|
-
def escape_html_safe(html)
|
18
|
-
html.html_safe? ? html : escape_html(html)
|
18
|
+
def escape_html_safe(html, safe = true)
|
19
|
+
safe && html.html_safe? ? html : escape_html(html)
|
19
20
|
end
|
20
21
|
|
21
22
|
if defined?(EscapeUtils)
|
data/lib/temple/version.rb
CHANGED
@@ -34,7 +34,7 @@ describe Temple::Filters::Escapable do
|
|
34
34
|
it 'should have use_html_safe option' do
|
35
35
|
filter = Temple::Filters::Escapable.new(:use_html_safe => true)
|
36
36
|
filter.call([:escape, true,
|
37
|
-
[:static,
|
37
|
+
[:static, Temple::HTML::SafeString.new("a < b")]
|
38
38
|
]).should.equal [:static, "a < b"]
|
39
39
|
end
|
40
40
|
|
data/test/helper.rb
CHANGED
@@ -1,20 +1,11 @@
|
|
1
1
|
require 'bacon'
|
2
2
|
require 'temple'
|
3
3
|
|
4
|
-
class HtmlSafeString < String
|
5
|
-
def html_safe?
|
6
|
-
true
|
7
|
-
end
|
8
|
-
|
9
|
-
def to_s
|
10
|
-
self
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
4
|
module TestHelper
|
15
5
|
def with_html_safe
|
6
|
+
require 'temple/html/safe'
|
16
7
|
String.send(:define_method, :html_safe?) { false }
|
17
|
-
String.send(:define_method, :html_safe) {
|
8
|
+
String.send(:define_method, :html_safe) { Temple::HTML::SafeString.new(self) }
|
18
9
|
yield
|
19
10
|
ensure
|
20
11
|
String.send(:undef_method, :html_safe?) if String.method_defined?(:html_safe?)
|
data/test/html/test_pretty.rb
CHANGED
@@ -22,7 +22,7 @@ describe Temple::HTML::Pretty do
|
|
22
22
|
[:static, "\n text"],
|
23
23
|
[:multi,
|
24
24
|
[:code, "_temple_html_pretty2 = (code).to_s"],
|
25
|
-
[:code, "if _temple_html_pretty1 !~ _temple_html_pretty2; _temple_html_pretty2 = _temple_html_pretty2.gsub(\"
|
25
|
+
[:code, "if _temple_html_pretty1 !~ _temple_html_pretty2; _temple_html_pretty2 = _temple_html_pretty2.gsub(\"\\n\", \"\\n \"); end"],
|
26
26
|
[:dynamic, "_temple_html_pretty2"]]],
|
27
27
|
[:static, "\n </p>"]],
|
28
28
|
[:static, "\n</div>"]]]
|
@@ -54,7 +54,7 @@ describe Temple::HTML::Pretty do
|
|
54
54
|
[:code, "_temple_html_pretty1 = /<code|<pre|<textarea/"],
|
55
55
|
[:multi,
|
56
56
|
[:code, "_temple_html_pretty2 = (\"text<\".html_safe).to_s"],
|
57
|
-
[:code, "if _temple_html_pretty1 !~ _temple_html_pretty2; _temple_html_pretty3 = _temple_html_pretty2.html_safe?; _temple_html_pretty2 = _temple_html_pretty2.gsub(\"
|
57
|
+
[:code, "if _temple_html_pretty1 !~ _temple_html_pretty2; _temple_html_pretty3 = _temple_html_pretty2.html_safe?; _temple_html_pretty2 = _temple_html_pretty2.gsub(\"\\n\", \"\\n\"); _temple_html_pretty2 = _temple_html_pretty2.html_safe if _temple_html_pretty3; end"],
|
58
58
|
[:dynamic, "_temple_html_pretty2"]]]
|
59
59
|
end
|
60
60
|
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.6.
|
4
|
+
version: 0.6.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Magnus Holm
|
@@ -9,48 +9,48 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-10-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: tilt
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '0'
|
21
21
|
type: :development
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: bacon
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '0'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: rake
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- -
|
46
|
+
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '0'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
description:
|
@@ -61,9 +61,9 @@ executables: []
|
|
61
61
|
extensions: []
|
62
62
|
extra_rdoc_files: []
|
63
63
|
files:
|
64
|
-
- .gitignore
|
65
|
-
- .travis.yml
|
66
|
-
- .yardopts
|
64
|
+
- ".gitignore"
|
65
|
+
- ".travis.yml"
|
66
|
+
- ".yardopts"
|
67
67
|
- CHANGES
|
68
68
|
- EXPRESSIONS.md
|
69
69
|
- Gemfile
|
@@ -103,6 +103,7 @@ files:
|
|
103
103
|
- lib/temple/html/fast.rb
|
104
104
|
- lib/temple/html/filter.rb
|
105
105
|
- lib/temple/html/pretty.rb
|
106
|
+
- lib/temple/html/safe.rb
|
106
107
|
- lib/temple/mixins/dispatcher.rb
|
107
108
|
- lib/temple/mixins/engine_dsl.rb
|
108
109
|
- lib/temple/mixins/grammar_dsl.rb
|
@@ -147,40 +148,19 @@ require_paths:
|
|
147
148
|
- lib
|
148
149
|
required_ruby_version: !ruby/object:Gem::Requirement
|
149
150
|
requirements:
|
150
|
-
- -
|
151
|
+
- - ">="
|
151
152
|
- !ruby/object:Gem::Version
|
152
153
|
version: '0'
|
153
154
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
154
155
|
requirements:
|
155
|
-
- -
|
156
|
+
- - ">="
|
156
157
|
- !ruby/object:Gem::Version
|
157
158
|
version: '0'
|
158
159
|
requirements: []
|
159
160
|
rubyforge_project:
|
160
|
-
rubygems_version: 2.
|
161
|
+
rubygems_version: 2.2.2
|
161
162
|
signing_key:
|
162
163
|
specification_version: 4
|
163
164
|
summary: Template compilation framework in Ruby
|
164
|
-
test_files:
|
165
|
-
|
166
|
-
- test/filters/test_control_flow.rb
|
167
|
-
- test/filters/test_dynamic_inliner.rb
|
168
|
-
- test/filters/test_eraser.rb
|
169
|
-
- test/filters/test_escapable.rb
|
170
|
-
- test/filters/test_multi_flattener.rb
|
171
|
-
- test/filters/test_static_merger.rb
|
172
|
-
- test/helper.rb
|
173
|
-
- test/html/test_attribute_merger.rb
|
174
|
-
- test/html/test_attribute_remover.rb
|
175
|
-
- test/html/test_attribute_sorter.rb
|
176
|
-
- test/html/test_fast.rb
|
177
|
-
- test/html/test_pretty.rb
|
178
|
-
- test/mixins/test_dispatcher.rb
|
179
|
-
- test/mixins/test_grammar_dsl.rb
|
180
|
-
- test/test_engine.rb
|
181
|
-
- test/test_erb.rb
|
182
|
-
- test/test_filter.rb
|
183
|
-
- test/test_generator.rb
|
184
|
-
- test/test_grammar.rb
|
185
|
-
- test/test_hash.rb
|
186
|
-
- test/test_utils.rb
|
165
|
+
test_files: []
|
166
|
+
has_rdoc:
|