temple 0.9.1 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES +7 -0
- data/Gemfile +0 -1
- data/lib/temple/erb/engine.rb +2 -0
- data/lib/temple/filters/string_splitter.rb +1 -1
- data/lib/temple/generator.rb +6 -12
- data/lib/temple/generators/rails_output_buffer.rb +6 -3
- data/lib/temple/templates/rails.rb +2 -2
- data/lib/temple/utils.rb +2 -1
- data/lib/temple/version.rb +1 -1
- data/spec/filters/string_splitter_spec.rb +1 -1
- data/spec/generator_spec.rb +0 -9
- data/temple.gemspec +0 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7475d628203a95d9ec067ac1388f8428cb213f4534a2fd2ed1b9cf0be7d3293
|
4
|
+
data.tar.gz: d828006ab486aee65e70e8e321022d28191deba994d43c1141dccad2815f41f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d74cc956889989a4d65f6727d7f521cbcbf3d9c2de1a6abda92b4957a7e3992de2b7de6c7634b4dfafe9d4ce1a505f22b8f5af1ef9a217876d6d67f276e04557
|
7
|
+
data.tar.gz: 1958e441fbab605e06f560db0f4c26e5fecf7c673a12a5aad843a3bd5bb4c0ce77e3c2ea13f46b22d962770898587b7f76bd0ad2b11377898e61924e7bc20c87
|
data/CHANGES
CHANGED
@@ -1,6 +1,13 @@
|
|
1
|
+
0.10.0
|
2
|
+
|
3
|
+
* Regression: Revert changes to :capture_generator since 0.8.2 (#112, #113, #137)
|
4
|
+
* Regression: Ensure that output buffer is not reused for capturing in Rails (#135)
|
5
|
+
* Drop support for Rails 4.x
|
6
|
+
|
1
7
|
0.9.1
|
2
8
|
|
3
9
|
* Fix Slim's error in AttributeMerger due to 0.9.0's :capture_generator (#137)
|
10
|
+
* Use specified :capture_generator for nested captures (#112)
|
4
11
|
* Fix Temple::ERB::Engine's <%= to not escape and <%== to escape expressions
|
5
12
|
|
6
13
|
0.9.0
|
data/Gemfile
CHANGED
data/lib/temple/erb/engine.rb
CHANGED
@@ -7,7 +7,7 @@ module Temple
|
|
7
7
|
module Filters
|
8
8
|
# Compile [:dynamic, "foo#{bar}"] to [:multi, [:static, 'foo'], [:dynamic, 'bar']]
|
9
9
|
class StringSplitter < Filter
|
10
|
-
if defined?(Ripper) &&
|
10
|
+
if defined?(Ripper) && Ripper.respond_to?(:lex)
|
11
11
|
class << self
|
12
12
|
# `code` param must be valid string literal
|
13
13
|
def compile(code)
|
data/lib/temple/generator.rb
CHANGED
@@ -10,9 +10,9 @@ module Temple
|
|
10
10
|
include Mixins::Options
|
11
11
|
|
12
12
|
define_options :save_buffer,
|
13
|
-
capture_generator:
|
13
|
+
capture_generator: 'StringBuffer',
|
14
14
|
buffer: '_buf',
|
15
|
-
freeze_static:
|
15
|
+
freeze_static: true
|
16
16
|
|
17
17
|
def call(exp)
|
18
18
|
[preamble, compile(exp), postamble].flatten.compact.join('; ')
|
@@ -54,7 +54,7 @@ module Temple
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def on_capture(name, exp)
|
57
|
-
capture_generator.new(
|
57
|
+
capture_generator.new(buffer: name).call(exp)
|
58
58
|
end
|
59
59
|
|
60
60
|
def on_static(text)
|
@@ -76,15 +76,9 @@ module Temple
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def capture_generator
|
79
|
-
@capture_generator ||=
|
80
|
-
|
81
|
-
|
82
|
-
self.class
|
83
|
-
when Class
|
84
|
-
options[:capture_generator]
|
85
|
-
else
|
86
|
-
Generators.const_get(options[:capture_generator])
|
87
|
-
end
|
79
|
+
@capture_generator ||= Class === options[:capture_generator] ?
|
80
|
+
options[:capture_generator] :
|
81
|
+
Generators.const_get(options[:capture_generator])
|
88
82
|
end
|
89
83
|
|
90
84
|
def concat(str)
|
@@ -9,10 +9,9 @@ module Temple
|
|
9
9
|
#
|
10
10
|
# @api public
|
11
11
|
class RailsOutputBuffer < StringBuffer
|
12
|
-
define_options :streaming,
|
12
|
+
define_options :streaming, # ignored
|
13
13
|
buffer_class: 'ActionView::OutputBuffer',
|
14
14
|
buffer: '@output_buffer',
|
15
|
-
# output_buffer is needed for Rails 3.1 Streaming support
|
16
15
|
capture_generator: RailsOutputBuffer
|
17
16
|
|
18
17
|
def call(exp)
|
@@ -20,7 +19,11 @@ module Temple
|
|
20
19
|
end
|
21
20
|
|
22
21
|
def create_buffer
|
23
|
-
|
22
|
+
if buffer == '@output_buffer'
|
23
|
+
"#{buffer} = output_buffer || #{options[:buffer_class]}.new"
|
24
|
+
else
|
25
|
+
"#{buffer} = #{options[:buffer_class]}.new"
|
26
|
+
end
|
24
27
|
end
|
25
28
|
|
26
29
|
def concat(str)
|
@@ -18,8 +18,8 @@ module Temple
|
|
18
18
|
|
19
19
|
def self.register_as(*names)
|
20
20
|
raise 'Rails is not loaded - Temple::Templates::Rails cannot be used' unless defined?(::ActionView)
|
21
|
-
if ::ActiveSupport::VERSION::MAJOR <
|
22
|
-
raise "Temple supports only Rails
|
21
|
+
if ::ActiveSupport::VERSION::MAJOR < 5
|
22
|
+
raise "Temple supports only Rails 5 and greater, your Rails version is #{::ActiveSupport::VERSION::STRING}"
|
23
23
|
end
|
24
24
|
names.each do |name|
|
25
25
|
::ActionView::Template.register_template_handler name.to_sym, new
|
data/lib/temple/utils.rb
CHANGED
@@ -14,7 +14,8 @@ module Temple
|
|
14
14
|
# @param html [String] The string to escape
|
15
15
|
# @return [String] The escaped string
|
16
16
|
def escape_html_safe(html)
|
17
|
-
|
17
|
+
s = html.to_s
|
18
|
+
s.html_safe? || html.html_safe? ? s : escape_html(s)
|
18
19
|
end
|
19
20
|
|
20
21
|
if defined?(CGI.escapeHTML)
|
data/lib/temple/version.rb
CHANGED
data/spec/generator_spec.rb
CHANGED
@@ -62,15 +62,6 @@ describe Temple::Generator do
|
|
62
62
|
'foo << (D:dynamic); C:code; foo; VAR << (S:after); VAR')
|
63
63
|
end
|
64
64
|
|
65
|
-
it 'should compile nested capture with the same capture_generator' do
|
66
|
-
gen = SimpleGenerator.new(buffer: "VAR", capture_generator: SimpleGenerator)
|
67
|
-
expect(gen.call([:capture, "foo", [:multi,
|
68
|
-
[:capture, "bar", [:multi,
|
69
|
-
[:static, "a"],
|
70
|
-
[:static, "b"]]]]
|
71
|
-
])).to eq "VAR = BUFFER; foo = BUFFER; bar = BUFFER; bar << (S:a); bar << (S:b); bar; foo; VAR"
|
72
|
-
end
|
73
|
-
|
74
65
|
it 'should compile newlines' do
|
75
66
|
gen = SimpleGenerator.new(buffer: "VAR")
|
76
67
|
expect(gen.call([:multi,
|
data/temple.gemspec
CHANGED
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.
|
4
|
+
version: 0.10.0
|
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:
|
12
|
+
date: 2023-01-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: tilt
|
@@ -178,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
178
178
|
- !ruby/object:Gem::Version
|
179
179
|
version: '0'
|
180
180
|
requirements: []
|
181
|
-
rubygems_version: 3.
|
181
|
+
rubygems_version: 3.2.5
|
182
182
|
signing_key:
|
183
183
|
specification_version: 4
|
184
184
|
summary: Template compilation framework in Ruby
|