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 +4 -4
- data/lib/tilt/coffee.rb +0 -12
- data/lib/tilt/erb.rb +1 -15
- data/lib/tilt/erubis.rb +1 -4
- data/lib/tilt/prawn.rb +3 -10
- data/lib/tilt/redcarpet.rb +19 -32
- data/lib/tilt/string.rb +5 -0
- data/lib/tilt/template.rb +5 -5
- data/lib/tilt.rb +3 -14
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42821dda310628574e4e1c99c69751d463bee48887c8f90c82768b80bb17231b
|
4
|
+
data.tar.gz: eb67c15726743517bf14d6db8b0034f7cbb7bd6c3c96d72ce24623430df03202
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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] ||
|
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) ||
|
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
|
-
|
19
|
-
|
20
|
-
|
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
|
|
data/lib/tilt/redcarpet.rb
CHANGED
@@ -4,41 +4,28 @@ require 'redcarpet'
|
|
4
4
|
|
5
5
|
aliases = {:escape_html => :filter_html, :smartypants => :smart}.freeze
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
-
|
27
|
-
|
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
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
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
|
-
|
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.
|
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.
|
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-
|
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
|