tilt 2.2.0 → 2.4.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/commonmarker.rb +83 -42
- data/lib/tilt/erb.rb +1 -15
- data/lib/tilt/erubis.rb +3 -4
- data/lib/tilt/etanni.rb +2 -2
- data/lib/tilt/maruku.rb +2 -0
- data/lib/tilt/prawn.rb +3 -10
- data/lib/tilt/redcarpet.rb +19 -32
- data/lib/tilt/sass.rb +15 -6
- data/lib/tilt/string.rb +5 -0
- data/lib/tilt/template.rb +5 -5
- data/lib/tilt/wikicloth.rb +2 -0
- data/lib/tilt.rb +3 -14
- 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: d9bb9bafc29e9442fed0bf862fb442ea6efaa97c2881b7b958361f0ef7095aaa
|
4
|
+
data.tar.gz: f25db1d4c05ef3b20c5fabefa4eb664e702f51f8d9821b0c44f5f5404ade4c3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc69e05565c5b007fbaaddc7636d6298fc9930c42d1e029834b752236309d97024132118bb723817c5c192cad1f1cef01e278ce4fc46629dac706d0ec4fdd6a2
|
7
|
+
data.tar.gz: 702e18b78c3e9b21e1abe86671bbe6f2427db44b05be4941c1693f30070f1de028af5324294d693bdeda130da603ecfd5c98dcefbce7ca21f7e7f6df5a249b97
|
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/commonmarker.rb
CHANGED
@@ -2,53 +2,94 @@
|
|
2
2
|
require_relative 'template'
|
3
3
|
require 'commonmarker'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
].freeze
|
5
|
+
if defined?(::Commonmarker)
|
6
|
+
aliases = {
|
7
|
+
:smartypants => :smart
|
8
|
+
}.freeze
|
9
|
+
parse_opts = [
|
10
|
+
:smart,
|
11
|
+
:default_info_string,
|
12
|
+
].freeze
|
13
|
+
render_opts = [
|
14
|
+
:hardbreaks,
|
15
|
+
:github_pre_lang,
|
16
|
+
:width,
|
17
|
+
:unsafe,
|
18
|
+
:escape,
|
19
|
+
:sourcepos,
|
20
|
+
].freeze
|
21
|
+
exts = [
|
22
|
+
:strikethrough,
|
23
|
+
:tagfilter,
|
24
|
+
:table,
|
25
|
+
:autolink,
|
26
|
+
:tasklist,
|
27
|
+
:superscript,
|
28
|
+
:header_ids,
|
29
|
+
:footnotes,
|
30
|
+
:description_lists,
|
31
|
+
:front_matter_delimiter,
|
32
|
+
:shortcodes,
|
33
|
+
].freeze
|
35
34
|
|
35
|
+
Tilt::CommonMarkerTemplate = Tilt::StaticTemplate.subclass do
|
36
|
+
parse_options = @options.select { |key, _| parse_opts.include?(key.downcase) }.transform_keys(&:downcase)
|
37
|
+
parse_options.merge!(@options.select { |key, _| aliases.has_key?(key) }.transform_keys { |key| aliases[key] })
|
38
|
+
render_options = @options.select { |key, _| render_opts.include?(key.downcase) }.transform_keys(&:downcase)
|
39
|
+
extensions = @options.select { |key, _| exts.include?(key) }.transform_keys(&:downcase)
|
36
40
|
|
37
|
-
|
38
|
-
extensions = exts.select do |extension|
|
39
|
-
@options[extension]
|
41
|
+
Commonmarker.to_html(@data, options: { parse: parse_options, render: render_options, extension: extensions })
|
40
42
|
end
|
43
|
+
# :nocov:
|
44
|
+
else
|
45
|
+
aliases = {
|
46
|
+
:smartypants => :SMART
|
47
|
+
}.freeze
|
48
|
+
parse_opts = [
|
49
|
+
:FOOTNOTES,
|
50
|
+
:LIBERAL_HTML_TAG,
|
51
|
+
:SMART,
|
52
|
+
:smartypants,
|
53
|
+
:STRIKETHROUGH_DOUBLE_TILDE,
|
54
|
+
:UNSAFE,
|
55
|
+
:VALIDATE_UTF8,
|
56
|
+
].freeze
|
57
|
+
render_opts = [
|
58
|
+
:FOOTNOTES,
|
59
|
+
:FULL_INFO_STRING,
|
60
|
+
:GITHUB_PRE_LANG,
|
61
|
+
:HARDBREAKS,
|
62
|
+
:NOBREAKS,
|
63
|
+
:SAFE, # Removed in v0.18.0 (2018-10-17)
|
64
|
+
:SOURCEPOS,
|
65
|
+
:TABLE_PREFER_STYLE_ATTRIBUTES,
|
66
|
+
:UNSAFE,
|
67
|
+
].freeze
|
68
|
+
exts = [
|
69
|
+
:autolink,
|
70
|
+
:strikethrough,
|
71
|
+
:table,
|
72
|
+
:tagfilter,
|
73
|
+
:tasklist,
|
74
|
+
].freeze
|
41
75
|
|
42
|
-
|
43
|
-
|
44
|
-
@options[
|
45
|
-
end.map! do |option|
|
46
|
-
aliases[option] || option
|
76
|
+
Tilt::CommonMarkerTemplate = Tilt::StaticTemplate.subclass do
|
77
|
+
extensions = exts.select do |extension|
|
78
|
+
@options[extension]
|
47
79
|
end
|
48
80
|
|
49
|
-
|
50
|
-
|
51
|
-
|
81
|
+
parse_options, render_options = [parse_opts, render_opts].map do |opts|
|
82
|
+
opts = opts.select do |option|
|
83
|
+
@options[option]
|
84
|
+
end.map! do |option|
|
85
|
+
aliases[option] || option
|
86
|
+
end
|
87
|
+
|
88
|
+
opts = :DEFAULT unless opts.any?
|
89
|
+
opts
|
90
|
+
end
|
52
91
|
|
53
|
-
|
92
|
+
CommonMarker.render_doc(@data, parse_options, extensions).to_html(render_options, extensions)
|
93
|
+
end
|
54
94
|
end
|
95
|
+
# :nocov:
|
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
@@ -2,6 +2,8 @@
|
|
2
2
|
require_relative 'erb'
|
3
3
|
require 'erubis'
|
4
4
|
|
5
|
+
warn 'tilt/erubis is deprecated, as erubis requires modifying string literals', uplevel: 1
|
6
|
+
|
5
7
|
module Tilt
|
6
8
|
# Erubis template implementation. See:
|
7
9
|
# http://www.kuwata-lab.com/erubis/
|
@@ -16,12 +18,9 @@ module Tilt
|
|
16
18
|
# the engine class instead of the default. All content
|
17
19
|
# within <%= %> blocks will be automatically html escaped.
|
18
20
|
class ErubisTemplate < ERBTemplate
|
19
|
-
# Remove in Tilt 2.3
|
20
|
-
@default_output_variable = nil
|
21
|
-
|
22
21
|
def prepare
|
23
22
|
@freeze_string_literals = !!@options.delete(:freeze)
|
24
|
-
@outvar = @options.delete(:outvar) ||
|
23
|
+
@outvar = @options.delete(:outvar) || '_erbout'
|
25
24
|
@options[:preamble] = false
|
26
25
|
@options[:postamble] = false
|
27
26
|
@options[:bufvar] = @outvar
|
data/lib/tilt/etanni.rb
CHANGED
@@ -5,7 +5,7 @@ module Tilt
|
|
5
5
|
class EtanniTemplate < Template
|
6
6
|
def prepare
|
7
7
|
separator = data.hash.abs
|
8
|
-
chomp = "<<#{separator}.chomp
|
8
|
+
chomp = "<<#{separator}.chomp"
|
9
9
|
start = "\n_out_ << #{chomp}\n"
|
10
10
|
stop = "\n#{separator}\n"
|
11
11
|
replacement = "#{stop}\\1#{start}"
|
@@ -13,7 +13,7 @@ module Tilt
|
|
13
13
|
temp = @data.strip
|
14
14
|
temp.gsub!(/<\?r\s+(.*?)\s+\?>/m, replacement)
|
15
15
|
|
16
|
-
@code = "_out_ = [<<#{separator}.chomp
|
16
|
+
@code = "_out_ = [<<#{separator}.chomp]\n#{temp}#{stop}_out_.join"
|
17
17
|
end
|
18
18
|
|
19
19
|
def precompiled_template(locals)
|
data/lib/tilt/maruku.rb
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
require_relative 'template'
|
3
3
|
require 'maruku'
|
4
4
|
|
5
|
+
warn 'tilt/maruku is deprecated, as maruku requires modifying string literals', uplevel: 1
|
6
|
+
|
5
7
|
# Maruku markdown implementation. See: https://github.com/bhollis/maruku
|
6
8
|
Tilt::MarukuTemplate = Tilt::StaticTemplate.subclass do
|
7
9
|
Maruku.new(@data, @options).to_html
|
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/sass.rb
CHANGED
@@ -13,6 +13,13 @@ module Tilt
|
|
13
13
|
# :nocov:
|
14
14
|
require 'uri'
|
15
15
|
|
16
|
+
ALLOWED_KEYS = (defined?(::Sass::Compiler) ? ::Sass::Compiler : ::Sass::Embedded).
|
17
|
+
instance_method(:compile_string).
|
18
|
+
parameters.
|
19
|
+
map{|k, v| v if k == :key}.
|
20
|
+
compact rescue nil
|
21
|
+
private_constant :ALLOWED_KEYS
|
22
|
+
|
16
23
|
private
|
17
24
|
|
18
25
|
def _prepare_output
|
@@ -22,9 +29,11 @@ module Tilt
|
|
22
29
|
def sass_options
|
23
30
|
path = File.absolute_path(eval_file)
|
24
31
|
path = '/' + path unless path.start_with?('/')
|
25
|
-
|
26
|
-
|
27
|
-
|
32
|
+
opts = @options.dup
|
33
|
+
opts[:url] = ::URI::File.build([nil, ::URI::DEFAULT_PARSER.escape(path)]).to_s
|
34
|
+
opts[:syntax] = :indented
|
35
|
+
opts.delete_if{|k| !ALLOWED_KEYS.include?(k)} if ALLOWED_KEYS
|
36
|
+
opts
|
28
37
|
end
|
29
38
|
rescue LoadError => err
|
30
39
|
begin
|
@@ -61,9 +70,9 @@ module Tilt
|
|
61
70
|
private
|
62
71
|
|
63
72
|
def sass_options
|
64
|
-
super
|
65
|
-
|
66
|
-
|
73
|
+
opts = super
|
74
|
+
opts[:syntax] = :scss
|
75
|
+
opts
|
67
76
|
end
|
68
77
|
end
|
69
78
|
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/wikicloth.rb
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
require_relative 'template'
|
3
3
|
require 'wikicloth'
|
4
4
|
|
5
|
+
warn 'tilt/wikicloth is deprecated, as wikicloth requires modifying string literals', uplevel: 1
|
6
|
+
|
5
7
|
# WikiCloth implementation. See: https://github.com/nricciar/wikicloth
|
6
8
|
Tilt::WikiClothTemplate = Tilt::StaticTemplate.subclass do
|
7
9
|
parser = @options.delete(:parser) || WikiCloth::Parser
|
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.4.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.4.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:
|
13
|
+
date: 2024-06-27 00:00:00.000000000 Z
|
14
14
|
dependencies: []
|
15
15
|
description: Generic interface to multiple Ruby template engines
|
16
16
|
email: code@jeremyevans.net
|
@@ -92,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: '0'
|
94
94
|
requirements: []
|
95
|
-
rubygems_version: 3.
|
95
|
+
rubygems_version: 3.5.9
|
96
96
|
signing_key:
|
97
97
|
specification_version: 4
|
98
98
|
summary: Generic interface to multiple Ruby template engines
|