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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ec5bd4c914592e35029369b132ae55d5ae56771b73d5c8710d3b6cbaf8c1409d
4
- data.tar.gz: 379717f7a2b6580cfe6e3732dcb8da6ff76f6adf2ec725cfc32eacd988f8471a
3
+ metadata.gz: c7475d628203a95d9ec067ac1388f8428cb213f4534a2fd2ed1b9cf0be7d3293
4
+ data.tar.gz: d828006ab486aee65e70e8e321022d28191deba994d43c1141dccad2815f41f2
5
5
  SHA512:
6
- metadata.gz: 938451e922d130af494c37d73612b35c53e05a94143d1cabff3e725b4512fbc4a04e1bf7acc27be0e8b37ebc7b00a2d9859e4f073c0941aeada7a1ed396889db
7
- data.tar.gz: f2925b82e2fb217f63d0afa4890c71f7ff6e209ee7775e33b9fb4a3885dce9bd638e46b8280f58f3f5002b020fd3e07792c560c3e44ed4b182dbfcefa2c66978
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
@@ -1,3 +1,2 @@
1
1
  source 'https://rubygems.org/'
2
2
  gemspec
3
- gem 'escape_utils' if ENV['ESCAPE_UTILS']
@@ -7,6 +7,8 @@ module Temple
7
7
  use Temple::ERB::Parser
8
8
  use Temple::ERB::Trimming
9
9
  filter :Escapable
10
+ filter :StringSplitter
11
+ filter :StaticAnalyzer
10
12
  filter :MultiFlattener
11
13
  filter :StaticMerger
12
14
  generator :ArrayBuffer
@@ -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) && RUBY_VERSION >= "2.0.0" && Ripper.respond_to?(:lex)
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)
@@ -10,9 +10,9 @@ module Temple
10
10
  include Mixins::Options
11
11
 
12
12
  define_options :save_buffer,
13
- capture_generator: :self,
13
+ capture_generator: 'StringBuffer',
14
14
  buffer: '_buf',
15
- freeze_static: RUBY_VERSION >= '2.1'
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(**options, buffer: name).call(exp)
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
- case options[:capture_generator]
81
- when :self
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
- "#{buffer} = output_buffer || #{options[:buffer_class]}.new"
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 < 3 || ::ActiveSupport::VERSION::MAJOR == 3 && ::ActiveSupport::VERSION::MINOR < 1
22
- raise "Temple supports only Rails 3.1 and greater, your Rails version is #{::ActiveSupport::VERSION::STRING}"
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
- html.html_safe? ? html : escape_html(html)
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)
@@ -1,3 +1,3 @@
1
1
  module Temple
2
- VERSION = '0.9.1'
2
+ VERSION = '0.10.0'
3
3
  end
@@ -4,7 +4,7 @@ begin
4
4
  rescue LoadError
5
5
  end
6
6
 
7
- if defined?(Ripper) && RUBY_VERSION >= "2.0.0"
7
+ if defined?(Ripper)
8
8
  describe Temple::Filters::StringSplitter do
9
9
  before do
10
10
  @filter = Temple::Filters::StringSplitter.new
@@ -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
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  require File.dirname(__FILE__) + '/lib/temple/version'
3
2
  require 'date'
4
3
 
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.9.1
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: 2022-10-25 00:00:00.000000000 Z
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.3.7
181
+ rubygems_version: 3.2.5
182
182
  signing_key:
183
183
  specification_version: 4
184
184
  summary: Template compilation framework in Ruby