tilt 2.2.0 → 2.3.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: 0b933744ac3dc007d759af22c61ea725d84e6d83a689c07e384792d08f330f60
4
- data.tar.gz: b07ad772a645934f3c0f912d2864eb9b47964b423a83d3cbc7978e6c90385229
3
+ metadata.gz: 42821dda310628574e4e1c99c69751d463bee48887c8f90c82768b80bb17231b
4
+ data.tar.gz: eb67c15726743517bf14d6db8b0034f7cbb7bd6c3c96d72ce24623430df03202
5
5
  SHA512:
6
- metadata.gz: 17e9ff63c011271c8fceb20c08f1c3d36f85c6674608690575ffc08b79b5d9704c0d63e456c00a2a0207295f54ef8c5df9f59c5de71680b1bf018faee93cba26
7
- data.tar.gz: fcffaeed7fba1e7f2bd9ec25f57426d544281cd434f8138253f5046f47e73a871770b4e8be1cb08349462b988a6101bbbca1f7ecc273bd74f457271eb3a84aa9
6
+ metadata.gz: 832ae277c35c2bb4fb36f93d2aaa411ec5ac948eb7d1eec956d70a1a54d27a2c4d326ae02bc5a75d06177aebb29d22cec4437ada71691ca25aba050fcad78236
7
+ data.tar.gz: ecc19aa399a14acc5c3d4f5adfc2d0bb70bf8d7552fd90ae7e4165cbad45b8f149e6cd808c49c0808762b6b9c68945dc6009a94c2910056a49f9e702637a8391
data/lib/tilt/coffee.rb CHANGED
@@ -15,18 +15,6 @@ module Tilt
15
15
  attr_accessor :default_bare
16
16
  end
17
17
 
18
- # :nocov:
19
- def self.default_no_wrap
20
- warn "#{self.class}.default_no_wrap is deprecated and will be removed in Tilt 2.3. Switch to #{self.class}.default_bare."
21
- default_bare
22
- end
23
-
24
- def self.default_no_wrap=(value)
25
- warn "#{self.class}.default_no_wrap= is deprecated and will be removed in Tilt 2.3. Switch to #{self.class}.default_bare=."
26
- self.default_bare = value
27
- end
28
- # :nocov:
29
-
30
18
  def self.literate?
31
19
  false
32
20
  end
data/lib/tilt/erb.rb CHANGED
@@ -8,23 +8,9 @@ module Tilt
8
8
  class ERBTemplate < Template
9
9
  SUPPORTS_KVARGS = ::ERB.instance_method(:initialize).parameters.assoc(:key) rescue false
10
10
 
11
- # Remove in Tilt 2.3
12
- @default_output_variable = nil
13
- def self._default_output_variable
14
- @default_output_variable
15
- end
16
- def self.default_output_variable
17
- warn "#{self}.default_output_variable is deprecated and will be removed in Tilt 2.3.", uplevel: 1
18
- @default_output_variable
19
- end
20
- def self.default_output_variable=(name)
21
- warn "#{self}.default_output_variable= is deprecated and will be removed in Tilt 2.3. Switch to using the :outvar option.", uplevel: 1
22
- @default_output_variable = name
23
- end
24
-
25
11
  def prepare
26
12
  @freeze_string_literals = !!@options[:freeze]
27
- @outvar = @options[:outvar] || self.class._default_output_variable || '_erbout'
13
+ @outvar = @options[:outvar] || '_erbout'
28
14
  trim = case @options[:trim]
29
15
  when false
30
16
  nil
data/lib/tilt/erubis.rb CHANGED
@@ -16,12 +16,9 @@ module Tilt
16
16
  # the engine class instead of the default. All content
17
17
  # within <%= %> blocks will be automatically html escaped.
18
18
  class ErubisTemplate < ERBTemplate
19
- # Remove in Tilt 2.3
20
- @default_output_variable = nil
21
-
22
19
  def prepare
23
20
  @freeze_string_literals = !!@options.delete(:freeze)
24
- @outvar = @options.delete(:outvar) || self.class._default_output_variable || '_erbout'
21
+ @outvar = @options.delete(:outvar) || '_erbout'
25
22
  @options[:preamble] = false
26
23
  @options[:postamble] = false
27
24
  @options[:bufvar] = @outvar
data/lib/tilt/prawn.rb CHANGED
@@ -15,16 +15,9 @@ module Tilt
15
15
 
16
16
  def evaluate(scope, locals, &block)
17
17
  pdf = @engine
18
- if @data.respond_to?(:to_str)
19
- locals = locals.dup
20
- locals[:pdf] = pdf
21
- super
22
- else
23
- warn "Non-string provided as prawn template data. This is no longer supported and support for it will be removed in Tilt 2.3", :uplevel=>2
24
- # :nocov:
25
- @data.call(pdf) if @data.kind_of?(Proc)
26
- # :nocov:
27
- end
18
+ locals = locals.dup
19
+ locals[:pdf] = pdf
20
+ super
28
21
  pdf.render
29
22
  end
30
23
 
@@ -4,41 +4,28 @@ require 'redcarpet'
4
4
 
5
5
  aliases = {:escape_html => :filter_html, :smartypants => :smart}.freeze
6
6
 
7
- # :nocov:
8
- unless defined? ::Redcarpet::Render and defined? ::Redcarpet::Markdown
9
- # Redcarpet 1.x
10
- warn "Tilt support for RedCarpet 1.x is deprecated and will be removed in Tilt 2.3", uplevel: 1
11
- _flags = [:smart, :filter_html, :smartypants, :escape_html]
12
-
13
- Tilt::RedcarpetTemplate = Tilt::StaticTemplate.subclass do
14
- flags = _flags.select { |flag| @options[flag] }.map! { |flag| aliases[flag] || flag }
15
- RedcarpetCompat.new(@data, *flags).to_html
16
- end
17
- # :nocov:
18
- else
19
- Tilt::RedcarpetTemplate = Tilt::StaticTemplate.subclass do
20
- aliases.each do |opt, aka|
21
- if options.key?(aka) || !@options.key?(opt)
22
- @options[opt] = @options.delete(aka)
23
- end
7
+ Tilt::RedcarpetTemplate = Tilt::StaticTemplate.subclass do
8
+ aliases.each do |opt, aka|
9
+ if options.key?(aka) || !@options.key?(opt)
10
+ @options[opt] = @options.delete(aka)
24
11
  end
12
+ end
25
13
 
26
- # only raise an exception if someone is trying to enable :escape_html
27
- @options.delete(:escape_html) unless @options[:escape_html]
14
+ # only raise an exception if someone is trying to enable :escape_html
15
+ @options.delete(:escape_html) unless @options[:escape_html]
28
16
 
29
- renderer = @options.delete(:renderer) || ::Redcarpet::Render::HTML.new(@options)
30
- if options.delete(:smartypants) && !(renderer.is_a?(Class) && renderer <= ::Redcarpet::Render::SmartyPants)
31
- renderer = if renderer == ::Redcarpet::Render::XHTML
32
- ::Redcarpet::Render::SmartyHTML.new(:xhtml => true)
33
- elsif renderer == ::Redcarpet::Render::HTML
34
- ::Redcarpet::Render::SmartyHTML
35
- elsif renderer.is_a? Class
36
- Class.new(renderer) { include ::Redcarpet::Render::SmartyPants }
37
- else
38
- renderer.extend ::Redcarpet::Render::SmartyPants
39
- end
17
+ renderer = @options.delete(:renderer) || ::Redcarpet::Render::HTML.new(@options)
18
+ if options.delete(:smartypants) && !(renderer.is_a?(Class) && renderer <= ::Redcarpet::Render::SmartyPants)
19
+ renderer = if renderer == ::Redcarpet::Render::XHTML
20
+ ::Redcarpet::Render::SmartyHTML.new(:xhtml => true)
21
+ elsif renderer == ::Redcarpet::Render::HTML
22
+ ::Redcarpet::Render::SmartyHTML
23
+ elsif renderer.is_a? Class
24
+ Class.new(renderer) { include ::Redcarpet::Render::SmartyPants }
25
+ else
26
+ renderer.extend ::Redcarpet::Render::SmartyPants
40
27
  end
41
-
42
- Redcarpet::Markdown.new(renderer, @options).render(@data)
43
28
  end
29
+
30
+ Redcarpet::Markdown.new(renderer, @options).render(@data)
44
31
  end
data/lib/tilt/string.rb CHANGED
@@ -7,6 +7,7 @@ module Tilt
7
7
  class StringTemplate < Template
8
8
  def prepare
9
9
  hash = "TILT#{@data.hash.abs}"
10
+ @freeze_string_literals = !!@options[:freeze]
10
11
  @code = String.new("<<#{hash}.chomp\n#{@data}\n#{hash}")
11
12
  end
12
13
 
@@ -18,5 +19,9 @@ module Tilt
18
19
  source, offset = super
19
20
  [source, offset + 1]
20
21
  end
22
+
23
+ def freeze_string_literals?
24
+ @freeze_string_literals
25
+ end
21
26
  end
22
27
  end
data/lib/tilt/template.rb CHANGED
@@ -99,11 +99,7 @@ module Tilt
99
99
  # block is given, it is typically available within the template via
100
100
  # +yield+.
101
101
  def render(scope=nil, locals=nil, &block)
102
- current_template = Thread.current[:tilt_current_template]
103
- Thread.current[:tilt_current_template] = self
104
102
  evaluate(scope || Object.new, locals || EMPTY_HASH, &block)
105
- ensure
106
- Thread.current[:tilt_current_template] = current_template
107
103
  end
108
104
 
109
105
  # The basename of the template file.
@@ -355,7 +351,11 @@ module Tilt
355
351
  path << ".rb"
356
352
 
357
353
  # Wrap method source in a class block for the scope, so constant lookup works
358
- method_source = "class #{scope_class.name}\n#{method_source}\nend"
354
+ if freeze_string_literals?
355
+ method_source_prefix = "# frozen-string-literal: true\n"
356
+ method_source = method_source.sub(/\A# frozen-string-literal: true\n/, '')
357
+ end
358
+ method_source = "#{method_source_prefix}class #{scope_class.name}\n#{method_source}\nend"
359
359
 
360
360
  load_compiled_method(path, method_source)
361
361
  else
data/lib/tilt.rb CHANGED
@@ -5,7 +5,7 @@ require_relative 'tilt/template'
5
5
  # Namespace for Tilt. This module is not intended to be included anywhere.
6
6
  module Tilt
7
7
  # Current version.
8
- VERSION = '2.2.0'
8
+ VERSION = '2.3.0'
9
9
 
10
10
  EMPTY_HASH = {}.freeze
11
11
  private_constant :EMPTY_HASH
@@ -18,6 +18,8 @@ module Tilt
18
18
  # is called, all attempts to modify the default mapping will fail.
19
19
  # This also freezes Tilt itself.
20
20
  def self.finalize!
21
+ return self if @default_mapping.is_a?(FinalizedMapping)
22
+
21
23
  class << self
22
24
  prepend(Module.new do
23
25
  def lazy_map(*)
@@ -80,19 +82,6 @@ module Tilt
80
82
  @default_mapping.templates_for(file)
81
83
  end
82
84
 
83
- # @return the template object that is currently rendering.
84
- #
85
- # @example
86
- # tmpl = Tilt['index.erb'].new { '<%= Tilt.current_template %>' }
87
- # tmpl.render == tmpl.to_s
88
- #
89
- # @note This is currently an experimental feature and might return nil
90
- # in the future.
91
- def self.current_template
92
- warn "Tilt.current_template is deprecated and will be removed in Tilt 2.3", uplevel: 1
93
- Thread.current[:tilt_current_template]
94
- end
95
-
96
85
  class << self
97
86
  # @return [Tilt::Mapping] the main mapping object
98
87
  attr_reader :default_mapping
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tilt
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Tomayko
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-06-05 00:00:00.000000000 Z
13
+ date: 2023-09-14 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: Generic interface to multiple Ruby template engines
16
16
  email: code@jeremyevans.net