tilt 2.0.2 → 2.0.3
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/CHANGELOG.md +8 -0
- data/Gemfile +3 -0
- data/README.md +2 -0
- data/docs/TEMPLATES.md +4 -3
- data/lib/tilt.rb +9 -6
- data/lib/tilt/babel.rb +2 -1
- data/lib/tilt/builder.rb +4 -7
- data/lib/tilt/commonmarker.rb +21 -0
- data/lib/tilt/dummy.rb +3 -0
- data/lib/tilt/erubis.rb +1 -1
- data/lib/tilt/mapping.rb +28 -3
- data/lib/tilt/pandoc.rb +53 -0
- data/lib/tilt/string.rb +1 -1
- data/lib/tilt/template.rb +6 -3
- data/lib/tilt/typescript.rb +26 -0
- data/test/mytemplate.rb +2 -0
- data/test/tilt_buildertemplate_test.rb +5 -0
- data/test/tilt_commonmarkertemplate_test.rb +20 -0
- data/test/tilt_mapping_test.rb +17 -0
- data/test/tilt_markdown_test.rb +12 -0
- data/test/tilt_pandoctemplate_test.rb +56 -0
- data/test/tilt_typescript_test.rb +34 -0
- data/tilt.gemspec +10 -2
- metadata +13 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8eb5c664834658aea7cbcd313c91143dc6cbcf5
|
4
|
+
data.tar.gz: 445aed9e2cdf45b3ac7de7255df71730d82a6ee1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5fb808cca6eb518ec297aee474872872ffc38da481a643787c72eb51227f75fea5aa067f6766921ff3cdc16bbdf9ad098ca552da51134b7ee591a330f8318cd
|
7
|
+
data.tar.gz: b61b68cdf6c1fac47c7ef814afe4cc2c4445d345522d94248c54010237a6e439c0c835f64f40fd9412a5b65b9c90f660662c45acba48a868e060aaf74840d852
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## 2.0.3 (2016-05-12)
|
2
|
+
|
3
|
+
* Add Pandoc support (#276, jmuheim)
|
4
|
+
* Add CommonMark support (#282, raphink)
|
5
|
+
* Add TypeScript support (#278, nghitran)
|
6
|
+
* Work with frozen string literal (#274, jeremyevans)
|
7
|
+
* Add MIME type for Babel (#273, SaitoWu)
|
8
|
+
|
1
9
|
## 2.0.2 (2016-01-06)
|
2
10
|
|
3
11
|
* Pass options to Redcarpet (#250, hughbien)
|
data/Gemfile
CHANGED
@@ -21,6 +21,7 @@ group :primary do
|
|
21
21
|
gem 'less'
|
22
22
|
gem 'coffee-script'
|
23
23
|
gem 'babel-transpiler'
|
24
|
+
gem 'typescript-node'
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
@@ -36,6 +37,7 @@ group :secondary do
|
|
36
37
|
gem 'asciidoctor', '>= 0.1.0'
|
37
38
|
gem 'liquid'
|
38
39
|
gem 'maruku'
|
40
|
+
gem 'pandoc-ruby'
|
39
41
|
|
40
42
|
if RUBY_VERSION > '1.9.3'
|
41
43
|
gem 'prawn', '>= 2.0.0'
|
@@ -50,6 +52,7 @@ group :secondary do
|
|
50
52
|
gem 'redcarpet' if RUBY_VERSION > '1.8.7'
|
51
53
|
gem 'rdiscount', '>= 2.1.6' if RUBY_VERSION != '1.9.2'
|
52
54
|
gem 'RedCloth'
|
55
|
+
gem 'commonmarker' if RUBY_VERSION > '1.9.3'
|
53
56
|
end
|
54
57
|
|
55
58
|
platform :mri do
|
data/README.md
CHANGED
@@ -40,7 +40,9 @@ Support for these template engines is included with the package:
|
|
40
40
|
| Redcarpet | .markdown, .mkd, .md | redcarpet | Community |
|
41
41
|
| BlueCloth | .markdown, .mkd, .md | bluecloth | Community |
|
42
42
|
| Kramdown | .markdown, .mkd, .md | kramdown | Community |
|
43
|
+
| Pandoc | .markdown, .mkd, .md | pandoc | Community |
|
43
44
|
| Maruku | .markdown, .mkd, .md | maruku | Community |
|
45
|
+
| CommonMarker | .markdown, .mkd, .md | commonmarker | Community |
|
44
46
|
| RedCloth | .textile | redcloth | Community |
|
45
47
|
| RDoc | .rdoc | rdoc | Tilt team |
|
46
48
|
| Radius | .radius | radius | Community |
|
data/docs/TEMPLATES.md
CHANGED
@@ -44,6 +44,7 @@ implementations (depending on which are available on your system):
|
|
44
44
|
* Redcarpet - `Tilt::RedcarpetTemplate`
|
45
45
|
* BlueCloth - `Tilt::BlueClothTemplate`
|
46
46
|
* Kramdown - `Tilt::KramdownTemplate`
|
47
|
+
* Pandoc - `Tilt::PandocTemplate`
|
47
48
|
* Maruku - `Tilt::MarukuTemplate`
|
48
49
|
|
49
50
|
<a name='erb'></a>
|
@@ -432,6 +433,7 @@ Markdown formatted texts are converted to HTML with one of these libraries:
|
|
432
433
|
* Redcarpet - `Tilt::RedcarpetTemplate`
|
433
434
|
* BlueCloth - `Tilt::BlueClothTemplate`
|
434
435
|
* Kramdown - `Tilt::KramdownTemplate`
|
436
|
+
* Pandoc - `Tilt::PandocTemplate`
|
435
437
|
* Maruku - `Tilt::MarukuTemplate`
|
436
438
|
|
437
439
|
Tilt will use fallback mode (as documented in the README) for determining which
|
@@ -458,7 +460,7 @@ To wrap a Markdown formatted document with a layout:
|
|
458
460
|
### Options
|
459
461
|
|
460
462
|
Every implementation of Markdown *should* support these options, but there are
|
461
|
-
some known problems with the Kramdown and
|
463
|
+
some known problems with the Kramdown, Maruku and Pandoc engines.
|
462
464
|
|
463
465
|
#### `:smartypants => true|false`
|
464
466
|
|
@@ -474,7 +476,7 @@ Maruku ignores this option and always applies smart quotes (and nothing else).
|
|
474
476
|
Set `true` disallow raw HTML in Markdown contents. HTML is converted to
|
475
477
|
literal text by escaping `<` characters.
|
476
478
|
|
477
|
-
Kramdown and
|
479
|
+
Kramdown, Maruku and Pandoc don't support this option.
|
478
480
|
|
479
481
|
### See also
|
480
482
|
|
@@ -521,4 +523,3 @@ using this template engine within a threaded environment.
|
|
521
523
|
[rdiscount]: http://github.com/rtomayko/rdiscount/ "RDiscount"
|
522
524
|
[smartypants]: http://daringfireball.net/projects/smartypants/ "Smarty Pants"
|
523
525
|
[markdown]: http://en.wikipedia.org/wiki/Markdown "Markdown"
|
524
|
-
|
data/lib/tilt.rb
CHANGED
@@ -4,7 +4,7 @@ require 'tilt/template'
|
|
4
4
|
# Namespace for Tilt. This module is not intended to be included anywhere.
|
5
5
|
module Tilt
|
6
6
|
# Current version.
|
7
|
-
VERSION = '2.0.
|
7
|
+
VERSION = '2.0.3'
|
8
8
|
|
9
9
|
@default_mapping = Mapping.new
|
10
10
|
|
@@ -119,11 +119,13 @@ module Tilt
|
|
119
119
|
register_lazy :ErubisTemplate, 'tilt/erubis', 'erb', 'rhtml', 'erubis'
|
120
120
|
|
121
121
|
# Markdown
|
122
|
-
register_lazy :BlueClothTemplate,
|
123
|
-
register_lazy :MarukuTemplate,
|
124
|
-
register_lazy :KramdownTemplate,
|
125
|
-
register_lazy :RDiscountTemplate,
|
126
|
-
register_lazy :RedcarpetTemplate,
|
122
|
+
register_lazy :BlueClothTemplate, 'tilt/bluecloth', 'markdown', 'mkd', 'md'
|
123
|
+
register_lazy :MarukuTemplate, 'tilt/maruku', 'markdown', 'mkd', 'md'
|
124
|
+
register_lazy :KramdownTemplate, 'tilt/kramdown', 'markdown', 'mkd', 'md'
|
125
|
+
register_lazy :RDiscountTemplate, 'tilt/rdiscount', 'markdown', 'mkd', 'md'
|
126
|
+
register_lazy :RedcarpetTemplate, 'tilt/redcarpet', 'markdown', 'mkd', 'md'
|
127
|
+
register_lazy :CommonMarkerTemplate, 'tilt/commonmarker', 'markdown', 'mkd', 'md'
|
128
|
+
register_lazy :PandocTemplate, 'tilt/pandoc', 'markdown', 'mkd', 'md'
|
127
129
|
|
128
130
|
# Rest (sorted by name)
|
129
131
|
register_lazy :AsciidoctorTemplate, 'tilt/asciidoc', 'ad', 'adoc', 'asciidoc'
|
@@ -147,6 +149,7 @@ module Tilt
|
|
147
149
|
register_lazy :SassTemplate, 'tilt/sass', 'sass'
|
148
150
|
register_lazy :ScssTemplate, 'tilt/sass', 'scss'
|
149
151
|
register_lazy :StringTemplate, 'tilt/string', 'str'
|
152
|
+
register_lazy :TypeScriptTemplate, 'tilt/typescript', 'ts'
|
150
153
|
register_lazy :WikiClothTemplate, 'tilt/wikicloth', 'wiki', 'mediawiki', 'mw'
|
151
154
|
register_lazy :YajlTemplate, 'tilt/yajl', 'yajl'
|
152
155
|
|
data/lib/tilt/babel.rb
CHANGED
data/lib/tilt/builder.rb
CHANGED
@@ -7,20 +7,17 @@ module Tilt
|
|
7
7
|
class BuilderTemplate < Template
|
8
8
|
self.default_mime_type = 'text/xml'
|
9
9
|
|
10
|
-
def prepare
|
10
|
+
def prepare
|
11
|
+
options[:indent] ||= 2
|
12
|
+
end
|
11
13
|
|
12
14
|
def evaluate(scope, locals, &block)
|
15
|
+
xml = (locals[:xml] ||= ::Builder::XmlMarkup.new(options))
|
13
16
|
return super(scope, locals, &block) if data.respond_to?(:to_str)
|
14
|
-
xml = ::Builder::XmlMarkup.new(:indent => 2)
|
15
17
|
data.call(xml)
|
16
18
|
xml.target!
|
17
19
|
end
|
18
20
|
|
19
|
-
def precompiled_preamble(locals)
|
20
|
-
return super if locals.include? :xml
|
21
|
-
"xml = ::Builder::XmlMarkup.new(:indent => 2)\n#{super}"
|
22
|
-
end
|
23
|
-
|
24
21
|
def precompiled_postamble(locals)
|
25
22
|
"xml.target!"
|
26
23
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'tilt/template'
|
2
|
+
require 'commonmarker'
|
3
|
+
|
4
|
+
module Tilt
|
5
|
+
class CommonMarkerTemplate < Template
|
6
|
+
self.default_mime_type = 'text/html'
|
7
|
+
|
8
|
+
def prepare
|
9
|
+
@engine = nil
|
10
|
+
@output = nil
|
11
|
+
end
|
12
|
+
|
13
|
+
def evaluate(scope, locals, &block)
|
14
|
+
CommonMarker.render_html(data, :default)
|
15
|
+
end
|
16
|
+
|
17
|
+
def allows_script?
|
18
|
+
false
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/tilt/dummy.rb
ADDED
data/lib/tilt/erubis.rb
CHANGED
data/lib/tilt/mapping.rb
CHANGED
@@ -60,7 +60,7 @@ module Tilt
|
|
60
60
|
@lazy_map = other.lazy_map.dup
|
61
61
|
end
|
62
62
|
|
63
|
-
#
|
63
|
+
# Registers a lazy template implementation by file extension. You
|
64
64
|
# can have multiple lazy template implementations defined on the
|
65
65
|
# same file extension, in which case the template implementation
|
66
66
|
# defined *last* will be attempted loaded *first*.
|
@@ -254,10 +254,35 @@ module Tilt
|
|
254
254
|
raise first_failure if first_failure
|
255
255
|
end
|
256
256
|
|
257
|
+
# This is due to a bug in JRuby (see GH issue jruby/jruby#3585)
|
258
|
+
Tilt.autoload :Dummy, "tilt/dummy"
|
259
|
+
require "tilt/dummy"
|
260
|
+
AUTOLOAD_IS_BROKEN = Tilt.autoload?(:Dummy)
|
261
|
+
|
262
|
+
# The proper behavior (in MRI) for autoload? is to
|
263
|
+
# return `false` when the constant/file has been
|
264
|
+
# explicitly required.
|
265
|
+
#
|
266
|
+
# However, in JRuby it returns `true` even after it's
|
267
|
+
# been required. In that case it turns out that `defined?`
|
268
|
+
# returns `"constant"` if it exists and `nil` when it doesn't.
|
269
|
+
# This is actually a second bug: `defined?` should resolve
|
270
|
+
# autoload (aka. actually try to require the file).
|
271
|
+
#
|
272
|
+
# We use the second bug in order to resolve the first bug.
|
273
|
+
|
257
274
|
def constant_defined?(name)
|
258
275
|
name.split('::').inject(Object) do |scope, n|
|
259
|
-
|
260
|
-
|
276
|
+
if scope.autoload?(n)
|
277
|
+
if !AUTOLOAD_IS_BROKEN
|
278
|
+
return false
|
279
|
+
end
|
280
|
+
|
281
|
+
if eval("!defined?(scope::#{n})")
|
282
|
+
return false
|
283
|
+
end
|
284
|
+
end
|
285
|
+
return false if !scope.const_defined?(n)
|
261
286
|
scope.const_get(n)
|
262
287
|
end
|
263
288
|
end
|
data/lib/tilt/pandoc.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'tilt/template'
|
2
|
+
require 'pandoc-ruby'
|
3
|
+
|
4
|
+
module Tilt
|
5
|
+
# Pandoc markdown implementation. See:
|
6
|
+
# http://pandoc.org/
|
7
|
+
class PandocTemplate < Template
|
8
|
+
def prepare
|
9
|
+
@output = PandocRuby.convert(data, options_hash, *options_array).strip
|
10
|
+
end
|
11
|
+
|
12
|
+
def tilt_to_pandoc_mapping
|
13
|
+
{ :smartypants => [:smart, true],
|
14
|
+
:escape_html => [:f, 'markdown-raw_html']
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
def pandoc_optimised_options
|
19
|
+
options.inject({}) do |hash, option|
|
20
|
+
if tilt_to_pandoc_mapping.has_key?(option[0]) && option[1] === true
|
21
|
+
hash[tilt_to_pandoc_mapping[option[0]][0]] = tilt_to_pandoc_mapping[option[0]][1]
|
22
|
+
else
|
23
|
+
hash[option[0]] = option[1]
|
24
|
+
end
|
25
|
+
|
26
|
+
hash
|
27
|
+
end.merge({:to => :html})
|
28
|
+
end
|
29
|
+
|
30
|
+
def options_array
|
31
|
+
pandoc_optimised_options.map do |option|
|
32
|
+
option[0] if option[1] === true
|
33
|
+
end.compact
|
34
|
+
end
|
35
|
+
|
36
|
+
def options_hash
|
37
|
+
pandoc_optimised_options.inject({}) do |hash, option|
|
38
|
+
# next if option[1] === true
|
39
|
+
# next if option[1] === false
|
40
|
+
hash[option[0]] = option[1] unless option[1] === true or option[1] === false
|
41
|
+
hash
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def evaluate(scope, locals, &block)
|
46
|
+
@output
|
47
|
+
end
|
48
|
+
|
49
|
+
def allows_script?
|
50
|
+
false
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/lib/tilt/string.rb
CHANGED
data/lib/tilt/template.rb
CHANGED
@@ -79,7 +79,10 @@ module Tilt
|
|
79
79
|
@data = @reader.call(self)
|
80
80
|
|
81
81
|
if @data.respond_to?(:force_encoding)
|
82
|
-
|
82
|
+
if default_encoding
|
83
|
+
@data = @data.dup if @data.frozen?
|
84
|
+
@data.force_encoding(default_encoding)
|
85
|
+
end
|
83
86
|
|
84
87
|
if !@data.valid_encoding?
|
85
88
|
raise Encoding::InvalidByteSequenceError, "#{eval_file} is not valid #{@data.encoding}"
|
@@ -177,7 +180,7 @@ module Tilt
|
|
177
180
|
preamble = precompiled_preamble(local_keys)
|
178
181
|
template = precompiled_template(local_keys)
|
179
182
|
postamble = precompiled_postamble(local_keys)
|
180
|
-
source =
|
183
|
+
source = String.new
|
181
184
|
|
182
185
|
# Ensure that our generated source code has the same encoding as the
|
183
186
|
# the source code generated by the template engine.
|
@@ -246,7 +249,7 @@ module Tilt
|
|
246
249
|
local_code = local_extraction(local_keys)
|
247
250
|
|
248
251
|
method_name = "__tilt_#{Thread.current.object_id.abs}"
|
249
|
-
method_source =
|
252
|
+
method_source = String.new
|
250
253
|
|
251
254
|
if method_source.respond_to?(:force_encoding)
|
252
255
|
method_source.force_encoding(source.encoding)
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'tilt/template'
|
2
|
+
require 'typescript-node'
|
3
|
+
|
4
|
+
module Tilt
|
5
|
+
class TypeScriptTemplate < Template
|
6
|
+
self.default_mime_type = 'application/javascript'
|
7
|
+
|
8
|
+
def prepare
|
9
|
+
@option_args = []
|
10
|
+
|
11
|
+
options.each do |key, value|
|
12
|
+
next unless value
|
13
|
+
|
14
|
+
@option_args << "--#{key}"
|
15
|
+
|
16
|
+
if value != true
|
17
|
+
@option_args << value.to_s
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def evaluate(scope, locals, &block)
|
23
|
+
@output ||= TypeScript::Node.compile(data, *@option_args)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/test/mytemplate.rb
ADDED
@@ -44,6 +44,11 @@ begin
|
|
44
44
|
assert_equal "<em>Hey Joe!</em>\n", template.render
|
45
45
|
end
|
46
46
|
|
47
|
+
test "options can be overridden" do
|
48
|
+
template = Tilt::BuilderTemplate.new(:indent => 0) { "xml.div { xml.em('Hey') }" }
|
49
|
+
assert_equal "<div><em>Hey</em></div>", template.render
|
50
|
+
end
|
51
|
+
|
47
52
|
test "allows nesting raw XML" do
|
48
53
|
subtemplate = Tilt::BuilderTemplate.new { "xml.em 'Hello World!'" }
|
49
54
|
template = Tilt::BuilderTemplate.new { "xml.strong { xml << yield }" }
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'tilt'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'tilt/commonmarker'
|
6
|
+
|
7
|
+
class CommonMarkerTemplateTest < Minitest::Test
|
8
|
+
test "preparing and evaluating templates on #render" do
|
9
|
+
template = Tilt::CommonMarkerTemplate.new { |t| "# Hello World!" }
|
10
|
+
assert_equal "<h1>Hello World!</h1>\n", template.render
|
11
|
+
end
|
12
|
+
|
13
|
+
test "can be rendered more than once" do
|
14
|
+
template = Tilt::CommonMarkerTemplate.new { |t| "# Hello World!" }
|
15
|
+
3.times { assert_equal "<h1>Hello World!</h1>\n", template.render }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
rescue LoadError => boom
|
19
|
+
warn "Tilt::CommonMarkerTemplate (disabled)"
|
20
|
+
end
|
data/test/tilt_mapping_test.rb
CHANGED
@@ -57,10 +57,12 @@ module Tilt
|
|
57
57
|
context "lazy with one template class" do
|
58
58
|
setup do
|
59
59
|
@mapping.register_lazy('MyTemplate', 'my_template', 'mt')
|
60
|
+
@loaded_before = $LOADED_FEATURES.dup
|
60
61
|
end
|
61
62
|
|
62
63
|
teardown do
|
63
64
|
Object.send :remove_const, :MyTemplate if defined? ::MyTemplate
|
65
|
+
$LOADED_FEATURES.replace(@loaded_before)
|
64
66
|
end
|
65
67
|
|
66
68
|
test "registered?" do
|
@@ -97,6 +99,21 @@ module Tilt
|
|
97
99
|
end
|
98
100
|
end
|
99
101
|
|
102
|
+
test "doesn't require when the template class is autoloaded, and then defined" do
|
103
|
+
Object.autoload :MyTemplate, 'mytemplate'
|
104
|
+
did_load = require 'mytemplate'
|
105
|
+
assert did_load, "mytemplate wasn't freshly required"
|
106
|
+
|
107
|
+
req = proc do |file|
|
108
|
+
flunk "#require shouldn't be called"
|
109
|
+
end
|
110
|
+
|
111
|
+
@mapping.stub :require, req do
|
112
|
+
klass = @mapping['hello.mt']
|
113
|
+
assert_equal ::MyTemplate, klass
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
100
117
|
test "raises NameError when the class name is defined" do
|
101
118
|
req = proc do |file|
|
102
119
|
# do nothing
|
data/test/tilt_markdown_test.rb
CHANGED
@@ -174,4 +174,16 @@ rescue LoadError
|
|
174
174
|
warn "Markdown tests need Nokogiri"
|
175
175
|
end
|
176
176
|
|
177
|
+
begin
|
178
|
+
require 'tilt/pandoc'
|
179
|
+
|
180
|
+
class MarkdownPandocTest < Minitest::Test
|
181
|
+
include MarkdownTests
|
182
|
+
template Tilt::PandocTemplate
|
177
183
|
|
184
|
+
# Doesn't support escaping
|
185
|
+
undef test_escape_html_true
|
186
|
+
end
|
187
|
+
rescue LoadError => boom
|
188
|
+
# It should already be warned in the main tests
|
189
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
require 'tilt'
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'tilt/pandoc'
|
8
|
+
|
9
|
+
class PandocTemplateTest < Minitest::Test
|
10
|
+
test "preparing and evaluating templates on #render" do
|
11
|
+
template = Tilt::PandocTemplate.new { |t| "# Hello World!" }
|
12
|
+
assert_equal "<h1 id=\"hello-world\">Hello World!</h1>", template.render.strip
|
13
|
+
end
|
14
|
+
|
15
|
+
test "can be rendered more than once" do
|
16
|
+
template = Tilt::PandocTemplate.new { |t| "# Hello World!" }
|
17
|
+
3.times { assert_equal "<h1 id=\"hello-world\">Hello World!</h1>", template.render.strip }
|
18
|
+
end
|
19
|
+
|
20
|
+
test "smartypants when :smartypants is set" do
|
21
|
+
template = Tilt::PandocTemplate.new(:smartypants => true) { |t| "OKAY -- 'Smarty Pants'" }
|
22
|
+
assert_equal "<p>OKAY – ‘Smarty Pants’</p>", template.render
|
23
|
+
end
|
24
|
+
|
25
|
+
test "stripping HTML when :escape_html is set" do
|
26
|
+
template = Tilt::PandocTemplate.new(:escape_html => true) { |t| "HELLO <blink>WORLD</blink>" }
|
27
|
+
assert_equal "<p>HELLO <blink>WORLD</blink></p>", template.render
|
28
|
+
end
|
29
|
+
|
30
|
+
# Pandoc has tons of additional markdown features (see http://pandoc.org/README.html#pandocs-markdown).
|
31
|
+
# The test for footnotes should be seen as a general representation for all of them.
|
32
|
+
test "generates footnotes" do
|
33
|
+
template = Tilt::PandocTemplate.new { |t| "Here is an inline note.^[Inlines notes are cool!]" }
|
34
|
+
assert_equal "<p>Here is an inline note.<a href=\"#fn1\" class=\"footnoteRef\" id=\"fnref1\"><sup>1</sup></a></p>\n<div class=\"footnotes\">\n<hr />\n<ol>\n<li id=\"fn1\"><p>Inlines notes are cool!<a href=\"#fnref1\">↩</a></p></li>\n</ol>\n</div>", template.render.strip
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "passing in Pandoc options" do
|
38
|
+
test "accepts arguments with values (e.g. :id_prefix => 'xyz')" do
|
39
|
+
# Table of contents isn't on by default
|
40
|
+
template = Tilt::PandocTemplate.new { |t| "# This is a heading" }
|
41
|
+
assert_equal "<h1 id=\"this-is-a-heading\">This is a heading</h1>", template.render
|
42
|
+
|
43
|
+
# But it can be activated
|
44
|
+
template = Tilt::PandocTemplate.new(:id_prefix => 'test-') { |t| "# This is a heading" }
|
45
|
+
assert_equal "<h1 id=\"test-this-is-a-heading\">This is a heading</h1>", template.render
|
46
|
+
end
|
47
|
+
|
48
|
+
test "requires arguments without value (e.g. --standalone) to be passed as hash keys (:standalone => true)" do
|
49
|
+
template = Tilt::PandocTemplate.new(:standalone => true) { |t| "# This is a heading" }
|
50
|
+
assert_match /^<!DOCTYPE html.*<h1 id="this-is-a-heading">This is a heading<\/h1>.*<\/html>$/m, template.render
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
rescue LoadError => boom
|
55
|
+
warn "Tilt::PandocTemplate (disabled)"
|
56
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'tilt'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'tilt/typescript'
|
6
|
+
|
7
|
+
class TypeScriptTemplateTest < Minitest::Test
|
8
|
+
def setup
|
9
|
+
@ts = "var x:number = 5"
|
10
|
+
@js = /var x = 5;\s*/
|
11
|
+
end
|
12
|
+
|
13
|
+
test "is registered for '.ts' files" do
|
14
|
+
assert_equal Tilt::TypeScriptTemplate, Tilt['test.ts']
|
15
|
+
end
|
16
|
+
|
17
|
+
test "compiles and evaluates the template on #render" do
|
18
|
+
template = Tilt::TypeScriptTemplate.new { @ts }
|
19
|
+
assert_match @js, template.render
|
20
|
+
end
|
21
|
+
|
22
|
+
test "supports source map" do
|
23
|
+
template = Tilt::TypeScriptTemplate.new(inlineSourceMap: true) { @ts }
|
24
|
+
assert_match /sourceMappingURL/, template.render
|
25
|
+
end
|
26
|
+
|
27
|
+
test "can be rendered more than once" do
|
28
|
+
template = Tilt::TypeScriptTemplate.new { @ts }
|
29
|
+
3.times { assert_match @js, template.render }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
rescue LoadError => boom
|
33
|
+
warn "Tilt::TypeScriptTemplate (disabled)"
|
34
|
+
end
|
data/tilt.gemspec
CHANGED
@@ -3,8 +3,8 @@ Gem::Specification.new do |s|
|
|
3
3
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
4
4
|
|
5
5
|
s.name = 'tilt'
|
6
|
-
s.version = '2.0.
|
7
|
-
s.date = '2016-
|
6
|
+
s.version = '2.0.3'
|
7
|
+
s.date = '2016-05-12'
|
8
8
|
|
9
9
|
s.description = "Generic interface to multiple Ruby template engines"
|
10
10
|
s.summary = s.description
|
@@ -30,8 +30,10 @@ Gem::Specification.new do |s|
|
|
30
30
|
lib/tilt/bluecloth.rb
|
31
31
|
lib/tilt/builder.rb
|
32
32
|
lib/tilt/coffee.rb
|
33
|
+
lib/tilt/commonmarker.rb
|
33
34
|
lib/tilt/creole.rb
|
34
35
|
lib/tilt/csv.rb
|
36
|
+
lib/tilt/dummy.rb
|
35
37
|
lib/tilt/erb.rb
|
36
38
|
lib/tilt/erubis.rb
|
37
39
|
lib/tilt/etanni.rb
|
@@ -43,6 +45,7 @@ Gem::Specification.new do |s|
|
|
43
45
|
lib/tilt/markaby.rb
|
44
46
|
lib/tilt/maruku.rb
|
45
47
|
lib/tilt/nokogiri.rb
|
48
|
+
lib/tilt/pandoc.rb
|
46
49
|
lib/tilt/plain.rb
|
47
50
|
lib/tilt/prawn.rb
|
48
51
|
lib/tilt/radius.rb
|
@@ -53,6 +56,7 @@ Gem::Specification.new do |s|
|
|
53
56
|
lib/tilt/sass.rb
|
54
57
|
lib/tilt/string.rb
|
55
58
|
lib/tilt/template.rb
|
59
|
+
lib/tilt/typescript.rb
|
56
60
|
lib/tilt/wikicloth.rb
|
57
61
|
lib/tilt/yajl.rb
|
58
62
|
man/index.txt
|
@@ -63,6 +67,7 @@ Gem::Specification.new do |s|
|
|
63
67
|
test/markaby/render_twice.mab
|
64
68
|
test/markaby/scope.mab
|
65
69
|
test/markaby/yielding.mab
|
70
|
+
test/mytemplate.rb
|
66
71
|
test/test_helper.rb
|
67
72
|
test/tilt_asciidoctor_test.rb
|
68
73
|
test/tilt_babeltemplate.rb
|
@@ -70,6 +75,7 @@ Gem::Specification.new do |s|
|
|
70
75
|
test/tilt_buildertemplate_test.rb
|
71
76
|
test/tilt_cache_test.rb
|
72
77
|
test/tilt_coffeescripttemplate_test.rb
|
78
|
+
test/tilt_commonmarkertemplate_test.rb
|
73
79
|
test/tilt_compilesite_test.rb
|
74
80
|
test/tilt_creoletemplate_test.rb
|
75
81
|
test/tilt_csv_test.rb
|
@@ -87,6 +93,7 @@ Gem::Specification.new do |s|
|
|
87
93
|
test/tilt_marukutemplate_test.rb
|
88
94
|
test/tilt_metadata_test.rb
|
89
95
|
test/tilt_nokogiritemplate_test.rb
|
96
|
+
test/tilt_pandoctemplate_test.rb
|
90
97
|
test/tilt_prawntemplate.prawn
|
91
98
|
test/tilt_prawntemplate_test.rb
|
92
99
|
test/tilt_radiustemplate_test.rb
|
@@ -98,6 +105,7 @@ Gem::Specification.new do |s|
|
|
98
105
|
test/tilt_stringtemplate_test.rb
|
99
106
|
test/tilt_template_test.rb
|
100
107
|
test/tilt_test.rb
|
108
|
+
test/tilt_typescript_test.rb
|
101
109
|
test/tilt_wikiclothtemplate_test.rb
|
102
110
|
test/tilt_yajltemplate_test.rb
|
103
111
|
tilt.gemspec
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tilt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Tomayko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Generic interface to multiple Ruby template engines
|
14
14
|
email: r@tomayko.com
|
@@ -32,8 +32,10 @@ files:
|
|
32
32
|
- lib/tilt/bluecloth.rb
|
33
33
|
- lib/tilt/builder.rb
|
34
34
|
- lib/tilt/coffee.rb
|
35
|
+
- lib/tilt/commonmarker.rb
|
35
36
|
- lib/tilt/creole.rb
|
36
37
|
- lib/tilt/csv.rb
|
38
|
+
- lib/tilt/dummy.rb
|
37
39
|
- lib/tilt/erb.rb
|
38
40
|
- lib/tilt/erubis.rb
|
39
41
|
- lib/tilt/etanni.rb
|
@@ -45,6 +47,7 @@ files:
|
|
45
47
|
- lib/tilt/markaby.rb
|
46
48
|
- lib/tilt/maruku.rb
|
47
49
|
- lib/tilt/nokogiri.rb
|
50
|
+
- lib/tilt/pandoc.rb
|
48
51
|
- lib/tilt/plain.rb
|
49
52
|
- lib/tilt/prawn.rb
|
50
53
|
- lib/tilt/radius.rb
|
@@ -55,6 +58,7 @@ files:
|
|
55
58
|
- lib/tilt/sass.rb
|
56
59
|
- lib/tilt/string.rb
|
57
60
|
- lib/tilt/template.rb
|
61
|
+
- lib/tilt/typescript.rb
|
58
62
|
- lib/tilt/wikicloth.rb
|
59
63
|
- lib/tilt/yajl.rb
|
60
64
|
- man/index.txt
|
@@ -65,6 +69,7 @@ files:
|
|
65
69
|
- test/markaby/render_twice.mab
|
66
70
|
- test/markaby/scope.mab
|
67
71
|
- test/markaby/yielding.mab
|
72
|
+
- test/mytemplate.rb
|
68
73
|
- test/test_helper.rb
|
69
74
|
- test/tilt_asciidoctor_test.rb
|
70
75
|
- test/tilt_babeltemplate.rb
|
@@ -72,6 +77,7 @@ files:
|
|
72
77
|
- test/tilt_buildertemplate_test.rb
|
73
78
|
- test/tilt_cache_test.rb
|
74
79
|
- test/tilt_coffeescripttemplate_test.rb
|
80
|
+
- test/tilt_commonmarkertemplate_test.rb
|
75
81
|
- test/tilt_compilesite_test.rb
|
76
82
|
- test/tilt_creoletemplate_test.rb
|
77
83
|
- test/tilt_csv_test.rb
|
@@ -89,6 +95,7 @@ files:
|
|
89
95
|
- test/tilt_marukutemplate_test.rb
|
90
96
|
- test/tilt_metadata_test.rb
|
91
97
|
- test/tilt_nokogiritemplate_test.rb
|
98
|
+
- test/tilt_pandoctemplate_test.rb
|
92
99
|
- test/tilt_prawntemplate.prawn
|
93
100
|
- test/tilt_prawntemplate_test.rb
|
94
101
|
- test/tilt_radiustemplate_test.rb
|
@@ -100,6 +107,7 @@ files:
|
|
100
107
|
- test/tilt_stringtemplate_test.rb
|
101
108
|
- test/tilt_template_test.rb
|
102
109
|
- test/tilt_test.rb
|
110
|
+
- test/tilt_typescript_test.rb
|
103
111
|
- test/tilt_wikiclothtemplate_test.rb
|
104
112
|
- test/tilt_yajltemplate_test.rb
|
105
113
|
- tilt.gemspec
|
@@ -139,6 +147,7 @@ test_files:
|
|
139
147
|
- test/tilt_buildertemplate_test.rb
|
140
148
|
- test/tilt_cache_test.rb
|
141
149
|
- test/tilt_coffeescripttemplate_test.rb
|
150
|
+
- test/tilt_commonmarkertemplate_test.rb
|
142
151
|
- test/tilt_compilesite_test.rb
|
143
152
|
- test/tilt_creoletemplate_test.rb
|
144
153
|
- test/tilt_csv_test.rb
|
@@ -155,6 +164,7 @@ test_files:
|
|
155
164
|
- test/tilt_marukutemplate_test.rb
|
156
165
|
- test/tilt_metadata_test.rb
|
157
166
|
- test/tilt_nokogiritemplate_test.rb
|
167
|
+
- test/tilt_pandoctemplate_test.rb
|
158
168
|
- test/tilt_prawntemplate_test.rb
|
159
169
|
- test/tilt_radiustemplate_test.rb
|
160
170
|
- test/tilt_rdiscounttemplate_test.rb
|
@@ -165,6 +175,7 @@ test_files:
|
|
165
175
|
- test/tilt_stringtemplate_test.rb
|
166
176
|
- test/tilt_template_test.rb
|
167
177
|
- test/tilt_test.rb
|
178
|
+
- test/tilt_typescript_test.rb
|
168
179
|
- test/tilt_wikiclothtemplate_test.rb
|
169
180
|
- test/tilt_yajltemplate_test.rb
|
170
181
|
has_rdoc:
|