tilt 2.1.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/COPYING +1 -0
- data/bin/tilt +2 -120
- data/lib/tilt/_emacs_org.rb +2 -0
- data/lib/tilt/_handlebars.rb +2 -0
- data/lib/tilt/_jbuilder.rb +2 -0
- data/lib/tilt/_org.rb +2 -0
- data/lib/tilt/asciidoc.rb +11 -23
- data/lib/tilt/babel.rb +5 -13
- data/lib/tilt/builder.rb +18 -13
- data/lib/tilt/cli.rb +134 -0
- data/lib/tilt/coffee.rb +12 -31
- data/lib/tilt/commonmarker.rb +47 -81
- data/lib/tilt/creole.rb +9 -20
- data/lib/tilt/csv.rb +5 -4
- data/lib/tilt/erb.rb +9 -17
- data/lib/tilt/erubi.rb +7 -6
- data/lib/tilt/erubis.rb +9 -6
- data/lib/tilt/etanni.rb +3 -2
- data/lib/tilt/haml.rb +12 -9
- data/lib/tilt/kramdown.rb +8 -20
- data/lib/tilt/liquid.rb +10 -14
- data/lib/tilt/livescript.rb +8 -20
- data/lib/tilt/mapping.rb +180 -104
- data/lib/tilt/markaby.rb +5 -7
- data/lib/tilt/maruku.rb +5 -19
- data/lib/tilt/nokogiri.rb +11 -10
- data/lib/tilt/pandoc.rb +33 -51
- data/lib/tilt/pipeline.rb +1 -0
- data/lib/tilt/plain.rb +4 -15
- data/lib/tilt/prawn.rb +10 -25
- data/lib/tilt/radius.rb +15 -22
- data/lib/tilt/rdiscount.rb +17 -33
- data/lib/tilt/rdoc.rb +14 -35
- data/lib/tilt/redcarpet.rb +20 -75
- data/lib/tilt/redcloth.rb +9 -19
- data/lib/tilt/rst-pandoc.rb +6 -19
- data/lib/tilt/sass.rb +34 -43
- data/lib/tilt/slim.rb +5 -0
- data/lib/tilt/string.rb +9 -3
- data/lib/tilt/template.rb +151 -61
- data/lib/tilt/typescript.rb +11 -18
- data/lib/tilt/wikicloth.rb +7 -19
- data/lib/tilt/yajl.rb +5 -11
- data/lib/tilt.rb +56 -40
- metadata +10 -7
- data/lib/tilt/bluecloth.rb +0 -26
- data/lib/tilt/less.rb +0 -32
- data/lib/tilt/sigil.rb +0 -36
data/lib/tilt.rb
CHANGED
@@ -1,78 +1,93 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require_relative 'tilt/mapping'
|
2
3
|
require_relative 'tilt/template'
|
3
4
|
|
4
5
|
# Namespace for Tilt. This module is not intended to be included anywhere.
|
5
6
|
module Tilt
|
6
7
|
# Current version.
|
7
|
-
VERSION = '2.
|
8
|
+
VERSION = '2.3.0'
|
9
|
+
|
10
|
+
EMPTY_HASH = {}.freeze
|
11
|
+
private_constant :EMPTY_HASH
|
8
12
|
|
9
13
|
@default_mapping = Mapping.new
|
10
14
|
|
11
|
-
|
12
|
-
|
13
|
-
|
15
|
+
# Replace the default mapping with a finalized version of the default
|
16
|
+
# mapping. This can be done to improve performance after the template
|
17
|
+
# libraries you desire to use have already been loaded. Once this is
|
18
|
+
# is called, all attempts to modify the default mapping will fail.
|
19
|
+
# This also freezes Tilt itself.
|
20
|
+
def self.finalize!
|
21
|
+
return self if @default_mapping.is_a?(FinalizedMapping)
|
22
|
+
|
23
|
+
class << self
|
24
|
+
prepend(Module.new do
|
25
|
+
def lazy_map(*)
|
26
|
+
raise "Tilt.#{__callee__} not supported after Tilt.finalize! has been called"
|
27
|
+
end
|
28
|
+
alias register lazy_map
|
29
|
+
alias register_lazy lazy_map
|
30
|
+
alias register_pipeline lazy_map
|
31
|
+
alias prefer lazy_map
|
32
|
+
end)
|
33
|
+
end
|
34
|
+
|
35
|
+
@default_mapping = @default_mapping.finalized
|
36
|
+
|
37
|
+
freeze
|
14
38
|
end
|
15
39
|
|
16
40
|
# @private
|
17
41
|
def self.lazy_map
|
18
|
-
default_mapping.lazy_map
|
42
|
+
@default_mapping.lazy_map
|
19
43
|
end
|
20
44
|
|
21
45
|
# @see Tilt::Mapping#register
|
22
46
|
def self.register(template_class, *extensions)
|
23
|
-
default_mapping.register(template_class, *extensions)
|
47
|
+
@default_mapping.register(template_class, *extensions)
|
24
48
|
end
|
25
49
|
|
26
50
|
# @see Tilt::Mapping#register_lazy
|
27
51
|
def self.register_lazy(class_name, file, *extensions)
|
28
|
-
default_mapping.register_lazy(class_name, file, *extensions)
|
52
|
+
@default_mapping.register_lazy(class_name, file, *extensions)
|
29
53
|
end
|
30
54
|
|
31
55
|
# @see Tilt::Mapping#register_pipeline
|
32
|
-
def self.register_pipeline(ext, options=
|
33
|
-
default_mapping.register_pipeline(ext, options)
|
34
|
-
end
|
35
|
-
|
36
|
-
# @deprecated Use {register} instead.
|
37
|
-
def self.prefer(template_class, *extensions)
|
38
|
-
register(template_class, *extensions)
|
56
|
+
def self.register_pipeline(ext, options=EMPTY_HASH)
|
57
|
+
@default_mapping.register_pipeline(ext, options)
|
39
58
|
end
|
40
59
|
|
41
60
|
# @see Tilt::Mapping#registered?
|
42
61
|
def self.registered?(ext)
|
43
|
-
default_mapping.registered?(ext)
|
62
|
+
@default_mapping.registered?(ext)
|
44
63
|
end
|
45
64
|
|
46
65
|
# @see Tilt::Mapping#new
|
47
|
-
def self.new(file, line=nil, options=
|
48
|
-
default_mapping.new(file, line, options, &block)
|
66
|
+
def self.new(file, line=nil, options=nil, &block)
|
67
|
+
@default_mapping.new(file, line, options, &block)
|
49
68
|
end
|
50
69
|
|
51
70
|
# @see Tilt::Mapping#[]
|
52
71
|
def self.[](file)
|
53
|
-
default_mapping[file]
|
72
|
+
@default_mapping[file]
|
54
73
|
end
|
55
74
|
|
56
75
|
# @see Tilt::Mapping#template_for
|
57
76
|
def self.template_for(file)
|
58
|
-
default_mapping.template_for(file)
|
77
|
+
@default_mapping.template_for(file)
|
59
78
|
end
|
60
79
|
|
61
80
|
# @see Tilt::Mapping#templates_for
|
62
81
|
def self.templates_for(file)
|
63
|
-
default_mapping.templates_for(file)
|
82
|
+
@default_mapping.templates_for(file)
|
64
83
|
end
|
65
84
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
# @note This is currently an experimental feature and might return nil
|
73
|
-
# in the future.
|
74
|
-
def self.current_template
|
75
|
-
Thread.current[:tilt_current_template]
|
85
|
+
class << self
|
86
|
+
# @return [Tilt::Mapping] the main mapping object
|
87
|
+
attr_reader :default_mapping
|
88
|
+
|
89
|
+
# Alias register as prefer for Tilt 1.x compatibility.
|
90
|
+
alias prefer register
|
76
91
|
end
|
77
92
|
|
78
93
|
# Extremely simple template cache implementation. Calling applications
|
@@ -115,7 +130,10 @@ module Tilt
|
|
115
130
|
@cache = {}
|
116
131
|
end
|
117
132
|
end
|
118
|
-
|
133
|
+
# :nocov:
|
134
|
+
# TILT3: Remove Tilt::Cache
|
135
|
+
deprecate_constant :Cache if respond_to?(:deprecate_constant, true)
|
136
|
+
# :nocov:
|
119
137
|
|
120
138
|
# Template Implementations ================================================
|
121
139
|
|
@@ -125,7 +143,6 @@ module Tilt
|
|
125
143
|
register_lazy :ErubiTemplate, 'tilt/erubi', 'erb', 'rhtml', 'erubi'
|
126
144
|
|
127
145
|
# Markdown
|
128
|
-
register_lazy :BlueClothTemplate, 'tilt/bluecloth', 'markdown', 'mkd', 'md'
|
129
146
|
register_lazy :MarukuTemplate, 'tilt/maruku', 'markdown', 'mkd', 'md'
|
130
147
|
register_lazy :KramdownTemplate, 'tilt/kramdown', 'markdown', 'mkd', 'md'
|
131
148
|
register_lazy :RDiscountTemplate, 'tilt/rdiscount', 'markdown', 'mkd', 'md'
|
@@ -143,7 +160,6 @@ module Tilt
|
|
143
160
|
register_lazy :CreoleTemplate, 'tilt/creole', 'wiki', 'creole'
|
144
161
|
register_lazy :EtanniTemplate, 'tilt/etanni', 'etn', 'etanni'
|
145
162
|
register_lazy :HamlTemplate, 'tilt/haml', 'haml'
|
146
|
-
register_lazy :LessTemplate, 'tilt/less', 'less'
|
147
163
|
register_lazy :LiquidTemplate, 'tilt/liquid', 'liquid'
|
148
164
|
register_lazy :LiveScriptTemplate, 'tilt/livescript','ls', 'livescript'
|
149
165
|
register_lazy :MarkabyTemplate, 'tilt/markaby', 'mab'
|
@@ -156,16 +172,16 @@ module Tilt
|
|
156
172
|
register_lazy :RstPandocTemplate, 'tilt/rst-pandoc', 'rst'
|
157
173
|
register_lazy :SassTemplate, 'tilt/sass', 'sass'
|
158
174
|
register_lazy :ScssTemplate, 'tilt/sass', 'scss'
|
159
|
-
register_lazy :
|
175
|
+
register_lazy :SlimTemplate, 'tilt/slim', 'slim'
|
160
176
|
register_lazy :StringTemplate, 'tilt/string', 'str'
|
161
177
|
register_lazy :TypeScriptTemplate, 'tilt/typescript', 'ts', 'tsx'
|
162
178
|
register_lazy :WikiClothTemplate, 'tilt/wikicloth', 'wiki', 'mediawiki', 'mw'
|
163
179
|
register_lazy :YajlTemplate, 'tilt/yajl', 'yajl'
|
164
180
|
|
165
|
-
#
|
166
|
-
|
167
|
-
register_lazy 'Tilt::HandlebarsTemplate', 'tilt/
|
168
|
-
register_lazy 'Tilt::OrgTemplate', '
|
169
|
-
register_lazy 'Tilt::
|
170
|
-
register_lazy 'Tilt::JbuilderTemplate', 'tilt/
|
181
|
+
# TILT3: Remove
|
182
|
+
# Deprecated lazy loading of external template engines
|
183
|
+
register_lazy 'Tilt::HandlebarsTemplate', 'tilt/_handlebars', 'handlebars', 'hbs'
|
184
|
+
register_lazy 'Tilt::OrgTemplate', 'tilt/_org', 'org'
|
185
|
+
register_lazy 'Tilt::OrgTemplate', 'tilt/_emacs_org', 'org'
|
186
|
+
register_lazy 'Tilt::JbuilderTemplate', 'tilt/_jbuilder', 'jbuilder'
|
171
187
|
end
|
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,10 +10,10 @@ 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
|
-
email:
|
16
|
+
email: code@jeremyevans.net
|
17
17
|
executables:
|
18
18
|
- tilt
|
19
19
|
extensions: []
|
@@ -22,10 +22,14 @@ files:
|
|
22
22
|
- COPYING
|
23
23
|
- bin/tilt
|
24
24
|
- lib/tilt.rb
|
25
|
+
- lib/tilt/_emacs_org.rb
|
26
|
+
- lib/tilt/_handlebars.rb
|
27
|
+
- lib/tilt/_jbuilder.rb
|
28
|
+
- lib/tilt/_org.rb
|
25
29
|
- lib/tilt/asciidoc.rb
|
26
30
|
- lib/tilt/babel.rb
|
27
|
-
- lib/tilt/bluecloth.rb
|
28
31
|
- lib/tilt/builder.rb
|
32
|
+
- lib/tilt/cli.rb
|
29
33
|
- lib/tilt/coffee.rb
|
30
34
|
- lib/tilt/commonmarker.rb
|
31
35
|
- lib/tilt/creole.rb
|
@@ -36,7 +40,6 @@ files:
|
|
36
40
|
- lib/tilt/etanni.rb
|
37
41
|
- lib/tilt/haml.rb
|
38
42
|
- lib/tilt/kramdown.rb
|
39
|
-
- lib/tilt/less.rb
|
40
43
|
- lib/tilt/liquid.rb
|
41
44
|
- lib/tilt/livescript.rb
|
42
45
|
- lib/tilt/mapping.rb
|
@@ -54,7 +57,7 @@ files:
|
|
54
57
|
- lib/tilt/redcloth.rb
|
55
58
|
- lib/tilt/rst-pandoc.rb
|
56
59
|
- lib/tilt/sass.rb
|
57
|
-
- lib/tilt/
|
60
|
+
- lib/tilt/slim.rb
|
58
61
|
- lib/tilt/string.rb
|
59
62
|
- lib/tilt/template.rb
|
60
63
|
- lib/tilt/typescript.rb
|
@@ -89,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
92
|
- !ruby/object:Gem::Version
|
90
93
|
version: '0'
|
91
94
|
requirements: []
|
92
|
-
rubygems_version: 3.4.
|
95
|
+
rubygems_version: 3.4.10
|
93
96
|
signing_key:
|
94
97
|
specification_version: 4
|
95
98
|
summary: Generic interface to multiple Ruby template engines
|
data/lib/tilt/bluecloth.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'tilt/template'
|
2
|
-
require 'bluecloth'
|
3
|
-
|
4
|
-
warn "Tilt::BlueClothTemplate is deprecated, please switch to a different markdown implementation"
|
5
|
-
|
6
|
-
module Tilt
|
7
|
-
# BlueCloth Markdown implementation. See:
|
8
|
-
# http://deveiate.org/projects/BlueCloth/
|
9
|
-
class BlueClothTemplate < Template
|
10
|
-
self.default_mime_type = 'text/html'
|
11
|
-
|
12
|
-
def prepare
|
13
|
-
@engine = BlueCloth.new(data, options)
|
14
|
-
@output = nil
|
15
|
-
end
|
16
|
-
|
17
|
-
def evaluate(scope, locals, &block)
|
18
|
-
@output ||= @engine.to_html
|
19
|
-
end
|
20
|
-
|
21
|
-
def allows_script?
|
22
|
-
false
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
data/lib/tilt/less.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'tilt/template'
|
2
|
-
require 'less'
|
3
|
-
|
4
|
-
warn "Tilt::LessTemplate is deprecated, consider switching from LESS to SCSS"
|
5
|
-
|
6
|
-
module Tilt
|
7
|
-
# Lessscss template implementation. See:
|
8
|
-
# http://lesscss.org/
|
9
|
-
#
|
10
|
-
# Less templates do not support object scopes, locals, or yield.
|
11
|
-
class LessTemplate < Template
|
12
|
-
self.default_mime_type = 'text/css'
|
13
|
-
|
14
|
-
def prepare
|
15
|
-
if ::Less.const_defined? :Engine
|
16
|
-
@engine = ::Less::Engine.new(data)
|
17
|
-
else
|
18
|
-
parser = ::Less::Parser.new(options.merge :filename => eval_file, :line => line)
|
19
|
-
@engine = parser.parse(data)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def evaluate(scope, locals, &block)
|
24
|
-
@output ||= @engine.to_css(options)
|
25
|
-
end
|
26
|
-
|
27
|
-
def allows_script?
|
28
|
-
false
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
data/lib/tilt/sigil.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'open3'
|
2
|
-
require 'shellwords'
|
3
|
-
|
4
|
-
warn "Tilt::SigilTemplate is deprecated"
|
5
|
-
|
6
|
-
module Tilt
|
7
|
-
# Standalone string interpolator and template processor implementation in Go.
|
8
|
-
# see: https://github.com/gliderlabs/sigil
|
9
|
-
class SigilTemplate < Template
|
10
|
-
def prepare
|
11
|
-
end
|
12
|
-
|
13
|
-
def evaluate(scope, locals, &block)
|
14
|
-
variables = locals.map {|k, v| "#{k}=#{v}" }
|
15
|
-
|
16
|
-
cmd = ['sigil']
|
17
|
-
|
18
|
-
unless variables.empty?
|
19
|
-
cmd << '-p'
|
20
|
-
cmd.concat(variables)
|
21
|
-
end
|
22
|
-
|
23
|
-
out, err, status = Open3.capture3(*cmd, :stdin_data => data)
|
24
|
-
|
25
|
-
if status.success?
|
26
|
-
out.chomp
|
27
|
-
else
|
28
|
-
raise err.chomp.gsub('<stdin>', file)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def allows_script?
|
33
|
-
false
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|