tilt 2.4.0 → 2.6.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/lib/tilt/creole.rb +2 -0
- data/lib/tilt/liquid.rb +0 -3
- data/lib/tilt/mapping.rb +3 -3
- data/lib/tilt/rdoc.rb +0 -8
- data/lib/tilt/template.rb +178 -27
- data/lib/tilt.rb +9 -4
- metadata +3 -9
- data/lib/tilt/erubis.rb +0 -51
- data/lib/tilt/maruku.rb +0 -10
- data/lib/tilt/wikicloth.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 950d868674b6de4ce7773935b2b9fd07c16528089320eaf0b3ab49be456cdf71
|
4
|
+
data.tar.gz: 720b39e51f933872fca6d768bb161ab08b96afeeafce3af69cbf81fa44a6ff58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85b22c88b5bc0f0b546336e80af4329760939d3cdf1777568774e09e894a4de92c3abce170f6f9e694997291782551ef3f285e732d2054680605bbb150e17adb
|
7
|
+
data.tar.gz: 86c570a4eb2c7e85169eea86be5607e8257aa8594dc50737f928e901ea9966634f452dc0c24b11baa836e86c201e55c20d6946df5a9c8ee40fe547feb573f4c0
|
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('
|
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
|
-
#
|
123
|
-
# back to `require "
|
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
@@ -57,7 +57,28 @@ module Tilt
|
|
57
57
|
# it should read template data and return as a String. When file is nil,
|
58
58
|
# a block is required.
|
59
59
|
#
|
60
|
-
# All arguments are optional.
|
60
|
+
# All arguments are optional. The following options are respected and
|
61
|
+
# are used by Tilt::Template itself and not the underlying template
|
62
|
+
# libraries:
|
63
|
+
#
|
64
|
+
# :default_encoding :: Force the encoding of the template to the given
|
65
|
+
# encoding.
|
66
|
+
# :skip_compiled_encoding_detection :: Do not scan template code for
|
67
|
+
# an encoding magic comment.
|
68
|
+
# :fixed_locals :: Force a specific method parameter signature, and call
|
69
|
+
# the method with a splat of locals, instead of passing
|
70
|
+
# the locals hash as a positional argument, and
|
71
|
+
# extracting locals from that. Should be a string
|
72
|
+
# containing the parameters for the compiled method,
|
73
|
+
# surrounded by parentheses. Can be set to false to
|
74
|
+
# disable the scan for embedded fixed locals.
|
75
|
+
# :extract_fixed_locals :: Whether embedded fixed locals should be scanned for
|
76
|
+
# and extracted from the template code.
|
77
|
+
# :default_fixed_locals :: Similar to fixed_locals, but lowest priority,
|
78
|
+
# only used if :fixed_locals is not provided
|
79
|
+
# and no embedded locals are found (or scanned for).
|
80
|
+
# :scope_class :: Force the scope class used for the method. By default,
|
81
|
+
# uses the class of the scope provided to render.
|
61
82
|
def initialize(file=nil, line=nil, options=nil)
|
62
83
|
@file, @line, @options = nil, 1, nil
|
63
84
|
|
@@ -69,7 +90,9 @@ module Tilt
|
|
69
90
|
|
70
91
|
@options ||= {}
|
71
92
|
|
72
|
-
|
93
|
+
# Force a specific scope class, instead of using the class of the provided
|
94
|
+
# scope as the scope class.
|
95
|
+
@scope_class = @options.delete :scope_class
|
73
96
|
|
74
97
|
# Force the encoding of the input data
|
75
98
|
@default_encoding = @options.delete :default_encoding
|
@@ -78,12 +101,19 @@ module Tilt
|
|
78
101
|
# for compiled templates
|
79
102
|
@skip_compiled_encoding_detection = @options.delete :skip_compiled_encoding_detection
|
80
103
|
|
104
|
+
# Compiled path to use. This must be specified as an option if
|
105
|
+
# providing the :scope_class option and using fixed locals,
|
106
|
+
# since template compilation occurs during initialization in that case.
|
107
|
+
if compiled_path = @options.delete(:compiled_path)
|
108
|
+
self.compiled_path = compiled_path
|
109
|
+
end
|
110
|
+
|
81
111
|
# load template data and prepare (uses binread to avoid encoding issues)
|
82
112
|
@data = block_given? ? yield(self) : read_template_file
|
83
113
|
|
84
114
|
if @data.respond_to?(:force_encoding)
|
85
115
|
if default_encoding
|
86
|
-
@data = @data
|
116
|
+
@data = _dup_string_if_frozen(@data)
|
87
117
|
@data.force_encoding(default_encoding)
|
88
118
|
end
|
89
119
|
|
@@ -92,7 +122,9 @@ module Tilt
|
|
92
122
|
end
|
93
123
|
end
|
94
124
|
|
125
|
+
set_fixed_locals
|
95
126
|
prepare
|
127
|
+
set_compiled_method_cache
|
96
128
|
end
|
97
129
|
|
98
130
|
# Render the template in the given scope with the locals specified. If a
|
@@ -119,6 +151,11 @@ module Tilt
|
|
119
151
|
@file || '(__TEMPLATE__)'
|
120
152
|
end
|
121
153
|
|
154
|
+
# Whether the template uses fixed locals.
|
155
|
+
def fixed_locals?
|
156
|
+
@fixed_locals ? true : false
|
157
|
+
end
|
158
|
+
|
122
159
|
# An empty Hash that the template engine can populate with various
|
123
160
|
# metadata.
|
124
161
|
def metadata
|
@@ -129,7 +166,14 @@ module Tilt
|
|
129
166
|
end
|
130
167
|
end
|
131
168
|
|
132
|
-
# Set the prefix to use for compiled paths
|
169
|
+
# Set the prefix to use for compiled paths, similar to using the
|
170
|
+
# :compiled_path template option. Note that this only
|
171
|
+
# has affect for future template compilations. When using the
|
172
|
+
# :scope_class template option, and using fixed_locals, calling
|
173
|
+
# this after the template is created has no effect, since the
|
174
|
+
# template is compiled during initialization in that case. It
|
175
|
+
# is recommended to use the :compiled_path template option
|
176
|
+
# instead of this method in new code.
|
133
177
|
def compiled_path=(path)
|
134
178
|
if path
|
135
179
|
# Use expanded paths when loading, since that is helpful
|
@@ -145,7 +189,18 @@ module Tilt
|
|
145
189
|
# directly on the scope class, which are much faster to call than
|
146
190
|
# Tilt's normal rendering.
|
147
191
|
def compiled_method(locals_keys, scope_class=nil)
|
148
|
-
|
192
|
+
if @fixed_locals
|
193
|
+
if @scope_class
|
194
|
+
return @compiled_method
|
195
|
+
else
|
196
|
+
key = scope_class
|
197
|
+
end
|
198
|
+
elsif @scope_class
|
199
|
+
key = locals_keys.dup.freeze
|
200
|
+
else
|
201
|
+
key = [scope_class, locals_keys].freeze
|
202
|
+
end
|
203
|
+
|
149
204
|
LOCK.synchronize do
|
150
205
|
if meth = @compiled_method[key]
|
151
206
|
return meth
|
@@ -181,7 +236,7 @@ module Tilt
|
|
181
236
|
end
|
182
237
|
|
183
238
|
CLASS_METHOD = Kernel.instance_method(:class)
|
184
|
-
USE_BIND_CALL = RUBY_VERSION >= '
|
239
|
+
USE_BIND_CALL = RUBY_VERSION >= '3'
|
185
240
|
|
186
241
|
# Execute the compiled template and return the result string. Template
|
187
242
|
# evaluation is guaranteed to be performed in the scope object with the
|
@@ -190,26 +245,25 @@ module Tilt
|
|
190
245
|
# This method is only used by source generating templates. Subclasses that
|
191
246
|
# override render() may not support all features.
|
192
247
|
def evaluate(scope, locals, &block)
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
case scope
|
197
|
-
when Object
|
198
|
-
scope_class = Module === scope ? scope : scope.class
|
248
|
+
if @fixed_locals
|
249
|
+
locals_keys = EMPTY_ARRAY
|
199
250
|
else
|
200
|
-
|
201
|
-
|
202
|
-
# :nocov:
|
251
|
+
locals_keys = locals.keys
|
252
|
+
locals_keys.sort!{|x, y| x.to_s <=> y.to_s}
|
203
253
|
end
|
204
|
-
method = compiled_method(locals_keys, scope_class)
|
205
254
|
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
255
|
+
unless scope_class = @scope_class
|
256
|
+
scope_class = case scope
|
257
|
+
when Object
|
258
|
+
Module === scope ? scope : scope.class
|
259
|
+
else
|
260
|
+
# :nocov:
|
261
|
+
USE_BIND_CALL ? CLASS_METHOD.bind_call(scope) : CLASS_METHOD.bind(scope).call
|
262
|
+
# :nocov:
|
263
|
+
end
|
212
264
|
end
|
265
|
+
|
266
|
+
evaluate_method(compiled_method(locals_keys, scope_class), scope, locals, &block)
|
213
267
|
end
|
214
268
|
|
215
269
|
# Generates all template source by combining the preamble, template, and
|
@@ -267,6 +321,18 @@ module Tilt
|
|
267
321
|
|
268
322
|
private
|
269
323
|
|
324
|
+
if RUBY_VERSION >= '2.3'
|
325
|
+
def _dup_string_if_frozen(string)
|
326
|
+
+string
|
327
|
+
end
|
328
|
+
# :nocov:
|
329
|
+
else
|
330
|
+
def _dup_string_if_frozen(string)
|
331
|
+
string.frozen? ? string.dup : string
|
332
|
+
end
|
333
|
+
end
|
334
|
+
# :nocov:
|
335
|
+
|
270
336
|
def process_arg(arg)
|
271
337
|
if arg
|
272
338
|
case
|
@@ -291,7 +357,12 @@ module Tilt
|
|
291
357
|
end
|
292
358
|
|
293
359
|
def set_compiled_method_cache
|
294
|
-
@compiled_method =
|
360
|
+
@compiled_method = if @fixed_locals && @scope_class
|
361
|
+
# No hash needed, only a single compiled method per template.
|
362
|
+
compile_template_method(EMPTY_ARRAY, @scope_class)
|
363
|
+
else
|
364
|
+
{}
|
365
|
+
end
|
295
366
|
end
|
296
367
|
|
297
368
|
def local_extraction(local_keys)
|
@@ -315,9 +386,39 @@ module Tilt
|
|
315
386
|
assignments.join("\n")
|
316
387
|
end
|
317
388
|
|
389
|
+
if USE_BIND_CALL
|
390
|
+
def evaluate_method(method, scope, locals, &block)
|
391
|
+
if @fixed_locals
|
392
|
+
method.bind_call(scope, **locals, &block)
|
393
|
+
else
|
394
|
+
method.bind_call(scope, locals, &block)
|
395
|
+
end
|
396
|
+
end
|
397
|
+
# :nocov:
|
398
|
+
else
|
399
|
+
def evaluate_method(method, scope, locals, &block)
|
400
|
+
if @fixed_locals
|
401
|
+
if locals.empty?
|
402
|
+
# Empty keyword splat on Ruby 2.0-2.6 passes empty hash
|
403
|
+
method.bind(scope).call(&block)
|
404
|
+
else
|
405
|
+
method.bind(scope).call(**locals, &block)
|
406
|
+
end
|
407
|
+
else
|
408
|
+
method.bind(scope).call(locals, &block)
|
409
|
+
end
|
410
|
+
end
|
411
|
+
end
|
412
|
+
# :nocov:
|
413
|
+
|
318
414
|
def compile_template_method(local_keys, scope_class=nil)
|
319
415
|
source, offset = precompiled(local_keys)
|
320
|
-
|
416
|
+
if @fixed_locals
|
417
|
+
method_args = @fixed_locals
|
418
|
+
else
|
419
|
+
method_args = "(locals)"
|
420
|
+
local_code = local_extraction(local_keys)
|
421
|
+
end
|
321
422
|
|
322
423
|
method_name = "__tilt_#{Thread.current.object_id.abs}"
|
323
424
|
method_source = String.new
|
@@ -328,7 +429,7 @@ module Tilt
|
|
328
429
|
end
|
329
430
|
|
330
431
|
# Don't indent method source, to avoid indentation warnings when using compiled paths
|
331
|
-
method_source << "::Tilt::TOPOBJECT.class_eval do\ndef #{method_name}
|
432
|
+
method_source << "::Tilt::TOPOBJECT.class_eval do\ndef #{method_name}#{method_args}\n#{local_code}\n"
|
332
433
|
|
333
434
|
offset += method_source.count("\n")
|
334
435
|
method_source << source
|
@@ -385,13 +486,49 @@ module Tilt
|
|
385
486
|
method
|
386
487
|
end
|
387
488
|
|
489
|
+
# Set the fixed locals for the template, which may be nil if no fixed locals can
|
490
|
+
# be determined.
|
491
|
+
def set_fixed_locals
|
492
|
+
fixed_locals = @options.delete(:fixed_locals)
|
493
|
+
extract_fixed_locals = @options.delete(:extract_fixed_locals)
|
494
|
+
default_fixed_locals = @options.delete(:default_fixed_locals)
|
495
|
+
|
496
|
+
if fixed_locals.nil?
|
497
|
+
if extract_fixed_locals.nil?
|
498
|
+
extract_fixed_locals = Tilt.extract_fixed_locals
|
499
|
+
end
|
500
|
+
|
501
|
+
if extract_fixed_locals
|
502
|
+
fixed_locals = extract_fixed_locals()
|
503
|
+
end
|
504
|
+
|
505
|
+
if fixed_locals.nil?
|
506
|
+
fixed_locals = default_fixed_locals
|
507
|
+
end
|
508
|
+
end
|
509
|
+
|
510
|
+
@fixed_locals = fixed_locals
|
511
|
+
end
|
512
|
+
|
513
|
+
# Extract fixed locals from the template code string. Should return nil
|
514
|
+
# if there are no fixed locals specified, or a method argument string
|
515
|
+
# surrounded by parentheses if there are fixed locals. The method
|
516
|
+
# argument string will be used when defining the template method if given.
|
517
|
+
def extract_fixed_locals
|
518
|
+
if @data.is_a?(String) && (match = /\#\s*locals:\s*(\(.*\))/.match(@data))
|
519
|
+
match[1]
|
520
|
+
end
|
521
|
+
end
|
522
|
+
|
388
523
|
def extract_encoding(script, &block)
|
389
524
|
extract_magic_comment(script, &block) || script.encoding
|
390
525
|
end
|
391
526
|
|
392
527
|
def extract_magic_comment(script)
|
393
|
-
|
394
|
-
|
528
|
+
was_frozen = script.frozen?
|
529
|
+
script = _dup_string_if_frozen(script)
|
530
|
+
|
531
|
+
if was_frozen
|
395
532
|
yield script
|
396
533
|
end
|
397
534
|
|
@@ -413,6 +550,16 @@ module Tilt
|
|
413
550
|
end
|
414
551
|
end
|
415
552
|
|
553
|
+
# Static templates are templates that return the same output for every render
|
554
|
+
#
|
555
|
+
# Instead of inheriting from the StaticTemplate class, you will use the .subclass
|
556
|
+
# method with a block which processes @data and returns the transformed value.
|
557
|
+
#
|
558
|
+
# Basic example which transforms the template to uppercase:
|
559
|
+
#
|
560
|
+
# UppercaseTemplate = Tilt::StaticTemplate.subclass do
|
561
|
+
# @data.upcase
|
562
|
+
# end
|
416
563
|
class StaticTemplate < Template
|
417
564
|
def self.subclass(mime_type: 'text/html', &block)
|
418
565
|
Class.new(self) do
|
@@ -451,5 +598,9 @@ module Tilt
|
|
451
598
|
# Do nothing, since compiled method cache is not used.
|
452
599
|
def set_compiled_method_cache
|
453
600
|
end
|
601
|
+
|
602
|
+
# Do nothing, since fixed locals are not used.
|
603
|
+
def set_fixed_locals
|
604
|
+
end
|
454
605
|
end
|
455
606
|
end
|
data/lib/tilt.rb
CHANGED
@@ -5,12 +5,16 @@ 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.6.0'
|
9
|
+
|
10
|
+
EMPTY_ARRAY = [].freeze
|
11
|
+
private_constant :EMPTY_ARRAY
|
9
12
|
|
10
13
|
EMPTY_HASH = {}.freeze
|
11
14
|
private_constant :EMPTY_HASH
|
12
15
|
|
13
16
|
@default_mapping = Mapping.new
|
17
|
+
@extract_fixed_locals = false
|
14
18
|
|
15
19
|
# Replace the default mapping with a finalized version of the default
|
16
20
|
# mapping. This can be done to improve performance after the template
|
@@ -86,6 +90,10 @@ module Tilt
|
|
86
90
|
# @return [Tilt::Mapping] the main mapping object
|
87
91
|
attr_reader :default_mapping
|
88
92
|
|
93
|
+
# Whether to extract fixed locals from templates by scanning the
|
94
|
+
# template content.
|
95
|
+
attr_accessor :extract_fixed_locals
|
96
|
+
|
89
97
|
# Alias register as prefer for Tilt 1.x compatibility.
|
90
98
|
alias prefer register
|
91
99
|
end
|
@@ -139,11 +147,9 @@ module Tilt
|
|
139
147
|
|
140
148
|
# ERB
|
141
149
|
register_lazy :ERBTemplate, 'tilt/erb', 'erb', 'rhtml'
|
142
|
-
register_lazy :ErubisTemplate, 'tilt/erubis', 'erb', 'rhtml', 'erubis'
|
143
150
|
register_lazy :ErubiTemplate, 'tilt/erubi', 'erb', 'rhtml', 'erubi'
|
144
151
|
|
145
152
|
# Markdown
|
146
|
-
register_lazy :MarukuTemplate, 'tilt/maruku', 'markdown', 'mkd', 'md'
|
147
153
|
register_lazy :KramdownTemplate, 'tilt/kramdown', 'markdown', 'mkd', 'md'
|
148
154
|
register_lazy :RDiscountTemplate, 'tilt/rdiscount', 'markdown', 'mkd', 'md'
|
149
155
|
register_lazy :RedcarpetTemplate, 'tilt/redcarpet', 'markdown', 'mkd', 'md'
|
@@ -175,7 +181,6 @@ module Tilt
|
|
175
181
|
register_lazy :SlimTemplate, 'tilt/slim', 'slim'
|
176
182
|
register_lazy :StringTemplate, 'tilt/string', 'str'
|
177
183
|
register_lazy :TypeScriptTemplate, 'tilt/typescript', 'ts', 'tsx'
|
178
|
-
register_lazy :WikiClothTemplate, 'tilt/wikicloth', 'wiki', 'mediawiki', 'mw'
|
179
184
|
register_lazy :YajlTemplate, 'tilt/yajl', 'yajl'
|
180
185
|
|
181
186
|
# TILT3: Remove
|
metadata
CHANGED
@@ -1,16 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tilt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Tomayko
|
8
8
|
- Magnus Holm
|
9
9
|
- Jeremy Evans
|
10
|
-
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date:
|
12
|
+
date: 2025-01-13 00:00:00.000000000 Z
|
14
13
|
dependencies: []
|
15
14
|
description: Generic interface to multiple Ruby template engines
|
16
15
|
email: code@jeremyevans.net
|
@@ -36,7 +35,6 @@ files:
|
|
36
35
|
- lib/tilt/csv.rb
|
37
36
|
- lib/tilt/erb.rb
|
38
37
|
- lib/tilt/erubi.rb
|
39
|
-
- lib/tilt/erubis.rb
|
40
38
|
- lib/tilt/etanni.rb
|
41
39
|
- lib/tilt/haml.rb
|
42
40
|
- lib/tilt/kramdown.rb
|
@@ -44,7 +42,6 @@ files:
|
|
44
42
|
- lib/tilt/livescript.rb
|
45
43
|
- lib/tilt/mapping.rb
|
46
44
|
- lib/tilt/markaby.rb
|
47
|
-
- lib/tilt/maruku.rb
|
48
45
|
- lib/tilt/nokogiri.rb
|
49
46
|
- lib/tilt/pandoc.rb
|
50
47
|
- lib/tilt/pipeline.rb
|
@@ -61,7 +58,6 @@ files:
|
|
61
58
|
- lib/tilt/string.rb
|
62
59
|
- lib/tilt/template.rb
|
63
60
|
- lib/tilt/typescript.rb
|
64
|
-
- lib/tilt/wikicloth.rb
|
65
61
|
- lib/tilt/yajl.rb
|
66
62
|
homepage: https://github.com/jeremyevans/tilt
|
67
63
|
licenses:
|
@@ -71,7 +67,6 @@ metadata:
|
|
71
67
|
changelog_uri: https://github.com/jeremyevans/tilt/blob/master/CHANGELOG.md
|
72
68
|
mailing_list_uri: https://github.com/jeremyevans/tilt/discussions
|
73
69
|
source_code_uri: https://github.com/jeremyevans/tilt
|
74
|
-
post_install_message:
|
75
70
|
rdoc_options:
|
76
71
|
- "--line-numbers"
|
77
72
|
- "--inline-source"
|
@@ -92,8 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
87
|
- !ruby/object:Gem::Version
|
93
88
|
version: '0'
|
94
89
|
requirements: []
|
95
|
-
rubygems_version: 3.
|
96
|
-
signing_key:
|
90
|
+
rubygems_version: 3.6.2
|
97
91
|
specification_version: 4
|
98
92
|
summary: Generic interface to multiple Ruby template engines
|
99
93
|
test_files: []
|
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
|
data/lib/tilt/wikicloth.rb
DELETED
@@ -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
|