tilt 2.4.0 → 2.5.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: d9bb9bafc29e9442fed0bf862fb442ea6efaa97c2881b7b958361f0ef7095aaa
4
- data.tar.gz: f25db1d4c05ef3b20c5fabefa4eb664e702f51f8d9821b0c44f5f5404ade4c3b
3
+ metadata.gz: 1386734fb6f20f9b1faf9e5edd4c83156e1d2e355141cd136ef949e956769e75
4
+ data.tar.gz: 52108af4de8efed7ade56f64e22d79fd3e5aaad4eb5ec36b2f0947242e102e57
5
5
  SHA512:
6
- metadata.gz: dc69e05565c5b007fbaaddc7636d6298fc9930c42d1e029834b752236309d97024132118bb723817c5c192cad1f1cef01e278ce4fc46629dac706d0ec4fdd6a2
7
- data.tar.gz: 702e18b78c3e9b21e1abe86671bbe6f2427db44b05be4941c1693f30070f1de028af5324294d693bdeda130da603ecfd5c98dcefbce7ca21f7e7f6df5a249b97
6
+ metadata.gz: 99a6e69ae4720ad5146c46b9b885fa4a4714b250d9db9168ae801d17f3146c90f25eab789401081100fdc065ae3ce3e804b79427e5ac835bd6bc576d3318a073
7
+ data.tar.gz: b0a44938aae6303bf03d174a942615e371669be99e4ec641a7a2b6ac0ee8d4f45f82869142f3e17b162efdd365883e909463763064b2b1b0417679652319c804
data/lib/tilt/creole.rb CHANGED
@@ -2,6 +2,8 @@
2
2
  require_relative 'template'
3
3
  require 'creole'
4
4
 
5
+ warn 'tilt/creole is deprecated, as creole requires modifying string literals', uplevel: 1
6
+
5
7
  allowed_opts = [:allowed_schemes, :extensions, :no_escape].freeze
6
8
 
7
9
  # Creole implementation. See: http://www.wikicreole.org/
data/lib/tilt/liquid.rb CHANGED
@@ -13,9 +13,6 @@ module Tilt
13
13
  # to #to_h it will be ignored.
14
14
  #
15
15
  # LiquidTemplate does not support yield blocks.
16
- #
17
- # It's suggested that your program require 'liquid' at load
18
- # time when using this template engine.
19
16
  class LiquidTemplate < Template
20
17
  def prepare
21
18
  @options[:line_numbers] = true unless @options.has_key?(:line_numbers)
data/lib/tilt/mapping.rb CHANGED
@@ -113,14 +113,14 @@ module Tilt
113
113
  # the exception of the first, since that was the most preferred one.
114
114
  #
115
115
  # mapping = Tilt::Mapping.new
116
- # mapping.register_lazy('Maruku::Template', 'maruku/template', 'md')
116
+ # mapping.register_lazy('Kramdown::Template', 'kramdown/template', 'md')
117
117
  # mapping.register_lazy('RDiscount::Template', 'rdiscount/template', 'md')
118
118
  # mapping['index.md']
119
119
  # # => RDiscount::Template
120
120
  #
121
121
  # In the previous example we say that RDiscount has a *higher priority* than
122
- # Maruku. Tilt will first try to `require "rdiscount/template"`, falling
123
- # back to `require "maruku/template"`. If none of these are successful,
122
+ # Kramdown. Tilt will first try to `require "rdiscount/template"`, falling
123
+ # back to `require "kramdown/template"`. If none of these are successful,
124
124
  # the first error will be raised.
125
125
  class Mapping < BaseMapping
126
126
  LOCK = Mutex.new
data/lib/tilt/rdoc.rb CHANGED
@@ -6,14 +6,6 @@ require 'rdoc/markup/to_html'
6
6
  require 'rdoc/options'
7
7
 
8
8
  # RDoc template. See: https://github.com/ruby/rdoc
9
- #
10
- # It's suggested that your program run the following at load time when
11
- # using this templae engine in a threaded environment:
12
- #
13
- # require 'rdoc'
14
- # require 'rdoc/markup'
15
- # require 'rdoc/markup/to_html'
16
- # require 'rdoc/options'
17
9
  Tilt::RDocTemplate = Tilt::StaticTemplate.subclass do
18
10
  RDoc::Markup::ToHtml.new(RDoc::Options.new, nil).convert(@data).to_s
19
11
  end
data/lib/tilt/template.rb CHANGED
@@ -83,7 +83,7 @@ module Tilt
83
83
 
84
84
  if @data.respond_to?(:force_encoding)
85
85
  if default_encoding
86
- @data = @data.dup if @data.frozen?
86
+ @data = _dup_string_if_frozen(@data)
87
87
  @data.force_encoding(default_encoding)
88
88
  end
89
89
 
@@ -267,6 +267,18 @@ module Tilt
267
267
 
268
268
  private
269
269
 
270
+ if RUBY_VERSION >= '2.3'
271
+ def _dup_string_if_frozen(string)
272
+ +string
273
+ end
274
+ # :nocov:
275
+ else
276
+ def _dup_string_if_frozen(string)
277
+ string.frozen? ? string.dup : string
278
+ end
279
+ end
280
+ # :nocov:
281
+
270
282
  def process_arg(arg)
271
283
  if arg
272
284
  case
@@ -390,8 +402,10 @@ module Tilt
390
402
  end
391
403
 
392
404
  def extract_magic_comment(script)
393
- if script.frozen?
394
- script = script.dup
405
+ was_frozen = script.frozen?
406
+ script = _dup_string_if_frozen(script)
407
+
408
+ if was_frozen
395
409
  yield script
396
410
  end
397
411
 
@@ -413,6 +427,16 @@ module Tilt
413
427
  end
414
428
  end
415
429
 
430
+ # Static templates are templates that return the same output for every render
431
+ #
432
+ # Instead of inheriting from the StaticTemplate class, you will use the .subclass
433
+ # method with a block which processes @data and returns the transformed value.
434
+ #
435
+ # Basic example which transforms the template to uppercase:
436
+ #
437
+ # UppercaseTemplate = Tilt::StaticTemplate.subclass do
438
+ # @data.upcase
439
+ # end
416
440
  class StaticTemplate < Template
417
441
  def self.subclass(mime_type: 'text/html', &block)
418
442
  Class.new(self) do
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.4.0'
8
+ VERSION = '2.5.0'
9
9
 
10
10
  EMPTY_HASH = {}.freeze
11
11
  private_constant :EMPTY_HASH
@@ -139,11 +139,9 @@ module Tilt
139
139
 
140
140
  # ERB
141
141
  register_lazy :ERBTemplate, 'tilt/erb', 'erb', 'rhtml'
142
- register_lazy :ErubisTemplate, 'tilt/erubis', 'erb', 'rhtml', 'erubis'
143
142
  register_lazy :ErubiTemplate, 'tilt/erubi', 'erb', 'rhtml', 'erubi'
144
143
 
145
144
  # Markdown
146
- register_lazy :MarukuTemplate, 'tilt/maruku', 'markdown', 'mkd', 'md'
147
145
  register_lazy :KramdownTemplate, 'tilt/kramdown', 'markdown', 'mkd', 'md'
148
146
  register_lazy :RDiscountTemplate, 'tilt/rdiscount', 'markdown', 'mkd', 'md'
149
147
  register_lazy :RedcarpetTemplate, 'tilt/redcarpet', 'markdown', 'mkd', 'md'
@@ -175,7 +173,6 @@ module Tilt
175
173
  register_lazy :SlimTemplate, 'tilt/slim', 'slim'
176
174
  register_lazy :StringTemplate, 'tilt/string', 'str'
177
175
  register_lazy :TypeScriptTemplate, 'tilt/typescript', 'ts', 'tsx'
178
- register_lazy :WikiClothTemplate, 'tilt/wikicloth', 'wiki', 'mediawiki', 'mw'
179
176
  register_lazy :YajlTemplate, 'tilt/yajl', 'yajl'
180
177
 
181
178
  # TILT3: Remove
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.0
4
+ version: 2.5.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: 2024-06-27 00:00:00.000000000 Z
13
+ date: 2024-12-20 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: Generic interface to multiple Ruby template engines
16
16
  email: code@jeremyevans.net
@@ -36,7 +36,6 @@ files:
36
36
  - lib/tilt/csv.rb
37
37
  - lib/tilt/erb.rb
38
38
  - lib/tilt/erubi.rb
39
- - lib/tilt/erubis.rb
40
39
  - lib/tilt/etanni.rb
41
40
  - lib/tilt/haml.rb
42
41
  - lib/tilt/kramdown.rb
@@ -44,7 +43,6 @@ files:
44
43
  - lib/tilt/livescript.rb
45
44
  - lib/tilt/mapping.rb
46
45
  - lib/tilt/markaby.rb
47
- - lib/tilt/maruku.rb
48
46
  - lib/tilt/nokogiri.rb
49
47
  - lib/tilt/pandoc.rb
50
48
  - lib/tilt/pipeline.rb
@@ -61,7 +59,6 @@ files:
61
59
  - lib/tilt/string.rb
62
60
  - lib/tilt/template.rb
63
61
  - lib/tilt/typescript.rb
64
- - lib/tilt/wikicloth.rb
65
62
  - lib/tilt/yajl.rb
66
63
  homepage: https://github.com/jeremyevans/tilt
67
64
  licenses:
@@ -92,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
89
  - !ruby/object:Gem::Version
93
90
  version: '0'
94
91
  requirements: []
95
- rubygems_version: 3.5.9
92
+ rubygems_version: 3.5.22
96
93
  signing_key:
97
94
  specification_version: 4
98
95
  summary: Generic interface to multiple Ruby template engines
data/lib/tilt/erubis.rb DELETED
@@ -1,51 +0,0 @@
1
- # frozen_string_literal: true
2
- require_relative 'erb'
3
- require 'erubis'
4
-
5
- warn 'tilt/erubis is deprecated, as erubis requires modifying string literals', uplevel: 1
6
-
7
- module Tilt
8
- # Erubis template implementation. See:
9
- # http://www.kuwata-lab.com/erubis/
10
- #
11
- # ErubisTemplate supports the following additional options, which are not
12
- # passed down to the Erubis engine:
13
- #
14
- # :engine_class allows you to specify a custom engine class to use
15
- # instead of the default (which is ::Erubis::Eruby).
16
- #
17
- # :escape_html when true, ::Erubis::EscapedEruby will be used as
18
- # the engine class instead of the default. All content
19
- # within <%= %> blocks will be automatically html escaped.
20
- class ErubisTemplate < ERBTemplate
21
- def prepare
22
- @freeze_string_literals = !!@options.delete(:freeze)
23
- @outvar = @options.delete(:outvar) || '_erbout'
24
- @options[:preamble] = false
25
- @options[:postamble] = false
26
- @options[:bufvar] = @outvar
27
- engine_class = @options.delete(:engine_class)
28
- engine_class = ::Erubis::EscapedEruby if @options.delete(:escape_html)
29
- @engine = (engine_class || ::Erubis::Eruby).new(@data, @options)
30
- end
31
-
32
- def precompiled_preamble(locals)
33
- [super, "#{@outvar} = _buf = String.new"].join("\n")
34
- end
35
-
36
- def precompiled_postamble(locals)
37
- [@outvar, super].join("\n")
38
- end
39
-
40
- # Erubis doesn't have ERB's line-off-by-one under 1.9 problem.
41
- # Override and adjust back.
42
- def precompiled(locals)
43
- source, offset = super
44
- [source, offset - 1]
45
- end
46
-
47
- def freeze_string_literals?
48
- @freeze_string_literals
49
- end
50
- end
51
- end
data/lib/tilt/maruku.rb DELETED
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
- require_relative 'template'
3
- require 'maruku'
4
-
5
- warn 'tilt/maruku is deprecated, as maruku requires modifying string literals', uplevel: 1
6
-
7
- # Maruku markdown implementation. See: https://github.com/bhollis/maruku
8
- Tilt::MarukuTemplate = Tilt::StaticTemplate.subclass do
9
- Maruku.new(@data, @options).to_html
10
- end
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
- require_relative 'template'
3
- require 'wikicloth'
4
-
5
- warn 'tilt/wikicloth is deprecated, as wikicloth requires modifying string literals', uplevel: 1
6
-
7
- # WikiCloth implementation. See: https://github.com/nricciar/wikicloth
8
- Tilt::WikiClothTemplate = Tilt::StaticTemplate.subclass do
9
- parser = @options.delete(:parser) || WikiCloth::Parser
10
- @options[:data] = @data
11
- parser.new(@options).to_html
12
- end