tilt 2.0.10 → 2.2.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.
Files changed (50) hide show
  1. checksums.yaml +5 -5
  2. data/COPYING +1 -0
  3. data/bin/tilt +2 -120
  4. data/lib/tilt/_emacs_org.rb +2 -0
  5. data/lib/tilt/_handlebars.rb +2 -0
  6. data/lib/tilt/_jbuilder.rb +2 -0
  7. data/lib/tilt/_org.rb +2 -0
  8. data/lib/tilt/asciidoc.rb +11 -23
  9. data/lib/tilt/babel.rb +5 -13
  10. data/lib/tilt/builder.rb +18 -13
  11. data/lib/tilt/cli.rb +134 -0
  12. data/lib/tilt/coffee.rb +18 -25
  13. data/lib/tilt/commonmarker.rb +47 -71
  14. data/lib/tilt/creole.rb +9 -20
  15. data/lib/tilt/csv.rb +6 -18
  16. data/lib/tilt/erb.rb +32 -16
  17. data/lib/tilt/erubi.rb +29 -6
  18. data/lib/tilt/erubis.rb +20 -11
  19. data/lib/tilt/etanni.rb +3 -2
  20. data/lib/tilt/haml.rb +73 -65
  21. data/lib/tilt/kramdown.rb +8 -20
  22. data/lib/tilt/liquid.rb +10 -14
  23. data/lib/tilt/livescript.rb +8 -20
  24. data/lib/tilt/mapping.rb +228 -109
  25. data/lib/tilt/markaby.rb +5 -7
  26. data/lib/tilt/maruku.rb +5 -19
  27. data/lib/tilt/nokogiri.rb +11 -10
  28. data/lib/tilt/pandoc.rb +33 -43
  29. data/lib/tilt/pipeline.rb +19 -0
  30. data/lib/tilt/plain.rb +4 -15
  31. data/lib/tilt/prawn.rb +15 -23
  32. data/lib/tilt/radius.rb +15 -22
  33. data/lib/tilt/rdiscount.rb +17 -33
  34. data/lib/tilt/rdoc.rb +14 -35
  35. data/lib/tilt/redcarpet.rb +25 -64
  36. data/lib/tilt/redcloth.rb +9 -19
  37. data/lib/tilt/rst-pandoc.rb +7 -15
  38. data/lib/tilt/sass.rb +45 -28
  39. data/lib/tilt/slim.rb +5 -0
  40. data/lib/tilt/string.rb +4 -3
  41. data/lib/tilt/template.rb +231 -73
  42. data/lib/tilt/typescript.rb +11 -18
  43. data/lib/tilt/wikicloth.rb +7 -19
  44. data/lib/tilt/yajl.rb +5 -11
  45. data/lib/tilt.rb +61 -29
  46. metadata +24 -16
  47. data/lib/tilt/bluecloth.rb +0 -24
  48. data/lib/tilt/dummy.rb +0 -3
  49. data/lib/tilt/less.rb +0 -30
  50. data/lib/tilt/sigil.rb +0 -34
data/lib/tilt.rb CHANGED
@@ -1,61 +1,83 @@
1
- require 'tilt/mapping'
2
- require 'tilt/template'
1
+ # frozen_string_literal: true
2
+ require_relative 'tilt/mapping'
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.0.10'
8
+ VERSION = '2.2.0'
9
+
10
+ EMPTY_HASH = {}.freeze
11
+ private_constant :EMPTY_HASH
8
12
 
9
13
  @default_mapping = Mapping.new
10
14
 
11
- # @return [Tilt::Mapping] the main mapping object
12
- def self.default_mapping
13
- @default_mapping
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
+ class << self
22
+ prepend(Module.new do
23
+ def lazy_map(*)
24
+ raise "Tilt.#{__callee__} not supported after Tilt.finalize! has been called"
25
+ end
26
+ alias register lazy_map
27
+ alias register_lazy lazy_map
28
+ alias register_pipeline lazy_map
29
+ alias prefer lazy_map
30
+ end)
31
+ end
32
+
33
+ @default_mapping = @default_mapping.finalized
34
+
35
+ freeze
14
36
  end
15
37
 
16
38
  # @private
17
39
  def self.lazy_map
18
- default_mapping.lazy_map
40
+ @default_mapping.lazy_map
19
41
  end
20
42
 
21
43
  # @see Tilt::Mapping#register
22
44
  def self.register(template_class, *extensions)
23
- default_mapping.register(template_class, *extensions)
45
+ @default_mapping.register(template_class, *extensions)
24
46
  end
25
47
 
26
48
  # @see Tilt::Mapping#register_lazy
27
49
  def self.register_lazy(class_name, file, *extensions)
28
- default_mapping.register_lazy(class_name, file, *extensions)
50
+ @default_mapping.register_lazy(class_name, file, *extensions)
29
51
  end
30
52
 
31
- # @deprecated Use {register} instead.
32
- def self.prefer(template_class, *extensions)
33
- register(template_class, *extensions)
53
+ # @see Tilt::Mapping#register_pipeline
54
+ def self.register_pipeline(ext, options=EMPTY_HASH)
55
+ @default_mapping.register_pipeline(ext, options)
34
56
  end
35
57
 
36
58
  # @see Tilt::Mapping#registered?
37
59
  def self.registered?(ext)
38
- default_mapping.registered?(ext)
60
+ @default_mapping.registered?(ext)
39
61
  end
40
62
 
41
63
  # @see Tilt::Mapping#new
42
- def self.new(file, line=nil, options={}, &block)
43
- default_mapping.new(file, line, options, &block)
64
+ def self.new(file, line=nil, options=nil, &block)
65
+ @default_mapping.new(file, line, options, &block)
44
66
  end
45
67
 
46
68
  # @see Tilt::Mapping#[]
47
69
  def self.[](file)
48
- default_mapping[file]
70
+ @default_mapping[file]
49
71
  end
50
72
 
51
73
  # @see Tilt::Mapping#template_for
52
74
  def self.template_for(file)
53
- default_mapping.template_for(file)
75
+ @default_mapping.template_for(file)
54
76
  end
55
77
 
56
78
  # @see Tilt::Mapping#templates_for
57
79
  def self.templates_for(file)
58
- default_mapping.templates_for(file)
80
+ @default_mapping.templates_for(file)
59
81
  end
60
82
 
61
83
  # @return the template object that is currently rendering.
@@ -67,9 +89,18 @@ module Tilt
67
89
  # @note This is currently an experimental feature and might return nil
68
90
  # in the future.
69
91
  def self.current_template
92
+ warn "Tilt.current_template is deprecated and will be removed in Tilt 2.3", uplevel: 1
70
93
  Thread.current[:tilt_current_template]
71
94
  end
72
95
 
96
+ class << self
97
+ # @return [Tilt::Mapping] the main mapping object
98
+ attr_reader :default_mapping
99
+
100
+ # Alias register as prefer for Tilt 1.x compatibility.
101
+ alias prefer register
102
+ end
103
+
73
104
  # Extremely simple template cache implementation. Calling applications
74
105
  # create a Tilt::Cache instance and use #fetch with any set of hashable
75
106
  # arguments (such as those to Tilt.new):
@@ -110,7 +141,10 @@ module Tilt
110
141
  @cache = {}
111
142
  end
112
143
  end
113
-
144
+ # :nocov:
145
+ # TILT3: Remove Tilt::Cache
146
+ deprecate_constant :Cache if respond_to?(:deprecate_constant, true)
147
+ # :nocov:
114
148
 
115
149
  # Template Implementations ================================================
116
150
 
@@ -120,7 +154,6 @@ module Tilt
120
154
  register_lazy :ErubiTemplate, 'tilt/erubi', 'erb', 'rhtml', 'erubi'
121
155
 
122
156
  # Markdown
123
- register_lazy :BlueClothTemplate, 'tilt/bluecloth', 'markdown', 'mkd', 'md'
124
157
  register_lazy :MarukuTemplate, 'tilt/maruku', 'markdown', 'mkd', 'md'
125
158
  register_lazy :KramdownTemplate, 'tilt/kramdown', 'markdown', 'mkd', 'md'
126
159
  register_lazy :RDiscountTemplate, 'tilt/rdiscount', 'markdown', 'mkd', 'md'
@@ -138,9 +171,8 @@ module Tilt
138
171
  register_lazy :CreoleTemplate, 'tilt/creole', 'wiki', 'creole'
139
172
  register_lazy :EtanniTemplate, 'tilt/etanni', 'etn', 'etanni'
140
173
  register_lazy :HamlTemplate, 'tilt/haml', 'haml'
141
- register_lazy :LessTemplate, 'tilt/less', 'less'
142
174
  register_lazy :LiquidTemplate, 'tilt/liquid', 'liquid'
143
- register_lazy :LiveScriptTemplate, 'tilt/livescript','ls'
175
+ register_lazy :LiveScriptTemplate, 'tilt/livescript','ls', 'livescript'
144
176
  register_lazy :MarkabyTemplate, 'tilt/markaby', 'mab'
145
177
  register_lazy :NokogiriTemplate, 'tilt/nokogiri', 'nokogiri'
146
178
  register_lazy :PlainTemplate, 'tilt/plain', 'html'
@@ -151,16 +183,16 @@ module Tilt
151
183
  register_lazy :RstPandocTemplate, 'tilt/rst-pandoc', 'rst'
152
184
  register_lazy :SassTemplate, 'tilt/sass', 'sass'
153
185
  register_lazy :ScssTemplate, 'tilt/sass', 'scss'
154
- register_lazy :SigilTemplate, 'tilt/sigil', 'sigil'
186
+ register_lazy :SlimTemplate, 'tilt/slim', 'slim'
155
187
  register_lazy :StringTemplate, 'tilt/string', 'str'
156
188
  register_lazy :TypeScriptTemplate, 'tilt/typescript', 'ts', 'tsx'
157
189
  register_lazy :WikiClothTemplate, 'tilt/wikicloth', 'wiki', 'mediawiki', 'mw'
158
190
  register_lazy :YajlTemplate, 'tilt/yajl', 'yajl'
159
191
 
160
- # External template engines
161
- register_lazy 'Slim::Template', 'slim', 'slim'
162
- register_lazy 'Tilt::HandlebarsTemplate', 'tilt/handlebars', 'handlebars', 'hbs'
163
- register_lazy 'Tilt::OrgTemplate', 'org-ruby', 'org'
164
- register_lazy 'Opal::Processor', 'opal', 'opal', 'rb'
165
- register_lazy 'Tilt::JbuilderTemplate', 'tilt/jbuilder', 'jbuilder'
192
+ # TILT3: Remove
193
+ # Deprecated lazy loading of external template engines
194
+ register_lazy 'Tilt::HandlebarsTemplate', 'tilt/_handlebars', 'handlebars', 'hbs'
195
+ register_lazy 'Tilt::OrgTemplate', 'tilt/_org', 'org'
196
+ register_lazy 'Tilt::OrgTemplate', 'tilt/_emacs_org', 'org'
197
+ register_lazy 'Tilt::JbuilderTemplate', 'tilt/_jbuilder', 'jbuilder'
166
198
  end
metadata CHANGED
@@ -1,17 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tilt
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.10
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Tomayko
8
- autorequire:
8
+ - Magnus Holm
9
+ - Jeremy Evans
10
+ autorequire:
9
11
  bindir: bin
10
12
  cert_chain: []
11
- date: 2019-09-23 00:00:00.000000000 Z
13
+ date: 2023-06-05 00:00:00.000000000 Z
12
14
  dependencies: []
13
15
  description: Generic interface to multiple Ruby template engines
14
- email: r@tomayko.com
16
+ email: code@jeremyevans.net
15
17
  executables:
16
18
  - tilt
17
19
  extensions: []
@@ -20,22 +22,24 @@ files:
20
22
  - COPYING
21
23
  - bin/tilt
22
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
23
29
  - lib/tilt/asciidoc.rb
24
30
  - lib/tilt/babel.rb
25
- - lib/tilt/bluecloth.rb
26
31
  - lib/tilt/builder.rb
32
+ - lib/tilt/cli.rb
27
33
  - lib/tilt/coffee.rb
28
34
  - lib/tilt/commonmarker.rb
29
35
  - lib/tilt/creole.rb
30
36
  - lib/tilt/csv.rb
31
- - lib/tilt/dummy.rb
32
37
  - lib/tilt/erb.rb
33
38
  - lib/tilt/erubi.rb
34
39
  - lib/tilt/erubis.rb
35
40
  - lib/tilt/etanni.rb
36
41
  - lib/tilt/haml.rb
37
42
  - lib/tilt/kramdown.rb
38
- - lib/tilt/less.rb
39
43
  - lib/tilt/liquid.rb
40
44
  - lib/tilt/livescript.rb
41
45
  - lib/tilt/mapping.rb
@@ -43,6 +47,7 @@ files:
43
47
  - lib/tilt/maruku.rb
44
48
  - lib/tilt/nokogiri.rb
45
49
  - lib/tilt/pandoc.rb
50
+ - lib/tilt/pipeline.rb
46
51
  - lib/tilt/plain.rb
47
52
  - lib/tilt/prawn.rb
48
53
  - lib/tilt/radius.rb
@@ -52,17 +57,21 @@ files:
52
57
  - lib/tilt/redcloth.rb
53
58
  - lib/tilt/rst-pandoc.rb
54
59
  - lib/tilt/sass.rb
55
- - lib/tilt/sigil.rb
60
+ - lib/tilt/slim.rb
56
61
  - lib/tilt/string.rb
57
62
  - lib/tilt/template.rb
58
63
  - lib/tilt/typescript.rb
59
64
  - lib/tilt/wikicloth.rb
60
65
  - lib/tilt/yajl.rb
61
- homepage: http://github.com/rtomayko/tilt/
66
+ homepage: https://github.com/jeremyevans/tilt
62
67
  licenses:
63
68
  - MIT
64
- metadata: {}
65
- post_install_message:
69
+ metadata:
70
+ bug_tracker_uri: https://github.com/jeremyevans/tilt/issues
71
+ changelog_uri: https://github.com/jeremyevans/tilt/blob/master/CHANGELOG.md
72
+ mailing_list_uri: https://github.com/jeremyevans/tilt/discussions
73
+ source_code_uri: https://github.com/jeremyevans/tilt
74
+ post_install_message:
66
75
  rdoc_options:
67
76
  - "--line-numbers"
68
77
  - "--inline-source"
@@ -76,16 +85,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
76
85
  requirements:
77
86
  - - ">="
78
87
  - !ruby/object:Gem::Version
79
- version: '0'
88
+ version: '2.0'
80
89
  required_rubygems_version: !ruby/object:Gem::Requirement
81
90
  requirements:
82
91
  - - ">="
83
92
  - !ruby/object:Gem::Version
84
93
  version: '0'
85
94
  requirements: []
86
- rubyforge_project:
87
- rubygems_version: 2.6.11
88
- signing_key:
89
- specification_version: 2
95
+ rubygems_version: 3.4.10
96
+ signing_key:
97
+ specification_version: 4
90
98
  summary: Generic interface to multiple Ruby template engines
91
99
  test_files: []
@@ -1,24 +0,0 @@
1
- require 'tilt/template'
2
- require 'bluecloth'
3
-
4
- module Tilt
5
- # BlueCloth Markdown implementation. See:
6
- # http://deveiate.org/projects/BlueCloth/
7
- class BlueClothTemplate < Template
8
- self.default_mime_type = 'text/html'
9
-
10
- def prepare
11
- @engine = BlueCloth.new(data, options)
12
- @output = nil
13
- end
14
-
15
- def evaluate(scope, locals, &block)
16
- @output ||= @engine.to_html
17
- end
18
-
19
- def allows_script?
20
- false
21
- end
22
- end
23
- end
24
-
data/lib/tilt/dummy.rb DELETED
@@ -1,3 +0,0 @@
1
- # Used for detecting autoloading bug in JRuby
2
- class Tilt::Dummy; end
3
-
data/lib/tilt/less.rb DELETED
@@ -1,30 +0,0 @@
1
- require 'tilt/template'
2
- require 'less'
3
-
4
- module Tilt
5
- # Lessscss template implementation. See:
6
- # http://lesscss.org/
7
- #
8
- # Less templates do not support object scopes, locals, or yield.
9
- class LessTemplate < Template
10
- self.default_mime_type = 'text/css'
11
-
12
- def prepare
13
- if ::Less.const_defined? :Engine
14
- @engine = ::Less::Engine.new(data)
15
- else
16
- parser = ::Less::Parser.new(options.merge :filename => eval_file, :line => line)
17
- @engine = parser.parse(data)
18
- end
19
- end
20
-
21
- def evaluate(scope, locals, &block)
22
- @output ||= @engine.to_css(options)
23
- end
24
-
25
- def allows_script?
26
- false
27
- end
28
- end
29
- end
30
-
data/lib/tilt/sigil.rb DELETED
@@ -1,34 +0,0 @@
1
- require 'open3'
2
- require 'shellwords'
3
-
4
- module Tilt
5
- # Standalone string interpolator and template processor implementation in Go.
6
- # see: https://github.com/gliderlabs/sigil
7
- class SigilTemplate < Template
8
- def prepare
9
- end
10
-
11
- def evaluate(scope, locals, &block)
12
- variables = locals.map {|k, v| "#{k}=#{v}" }
13
-
14
- cmd = ['sigil']
15
-
16
- unless variables.empty?
17
- cmd << '-p'
18
- cmd.concat(variables)
19
- end
20
-
21
- out, err, status = Open3.capture3(*cmd, :stdin_data => data)
22
-
23
- if status.success?
24
- out.chomp
25
- else
26
- raise err.chomp.gsub('<stdin>', file)
27
- end
28
- end
29
-
30
- def allows_script?
31
- false
32
- end
33
- end
34
- end