tilt 2.0.8 → 2.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile +6 -1
- data/README.md +1 -1
- data/Rakefile +1 -1
- data/lib/tilt.rb +1 -1
- data/lib/tilt/commonmarker.rb +58 -1
- data/lib/tilt/erb.rb +7 -1
- data/lib/tilt/haml.rb +2 -2
- data/lib/tilt/sass.rb +13 -2
- data/test/tilt_commonmarkertemplate_test.rb +8 -0
- data/test/tilt_sasstemplate_test.rb +2 -1
- data/tilt.gemspec +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 628b7587af284142a071a75dec94e684b6972d16
|
4
|
+
data.tar.gz: a686e34c2f8d764a74e2760fe5af2fc22c27b66d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b802450ebc32e4d50d65af2bf827bf8e6b92d85787ea9507701d70e6c0e8df911fce4402e53e99e95029d11daa4bcbca6ed99f5c90fa0235d0051d7a290a6446
|
7
|
+
data.tar.gz: a2db67256a1c846deabd6520d943e101645ea25cb610d022e60f2755dbddddfd8197275c6783ed663f569538647553714a1151d6d660887caf8ae6662b008159
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Tilt [![Build Status](https://secure.travis-ci.org/rtomayko/tilt.svg)](http://travis-ci.org/rtomayko/tilt) [![
|
1
|
+
Tilt [![Build Status](https://secure.travis-ci.org/rtomayko/tilt.svg)](http://travis-ci.org/rtomayko/tilt) [![Inline docs](http://inch-ci.org/github/rtomayko/tilt.svg)](http://inch-ci.org/github/rtomayko/tilt) [![Security](https://hakiri.io/github/rtomayko/tilt/master.svg)](https://hakiri.io/github/rtomayko/tilt/master)
|
2
2
|
====
|
3
3
|
|
4
4
|
**NOTE** The following file documents the current release of Tilt (2.0). See
|
data/Rakefile
CHANGED
data/lib/tilt.rb
CHANGED
data/lib/tilt/commonmarker.rb
CHANGED
@@ -5,13 +5,70 @@ module Tilt
|
|
5
5
|
class CommonMarkerTemplate < Template
|
6
6
|
self.default_mime_type = 'text/html'
|
7
7
|
|
8
|
+
OPTION_ALIAS = {
|
9
|
+
:smartypants => :SMART
|
10
|
+
}
|
11
|
+
PARSE_OPTIONS = [
|
12
|
+
:SMART,
|
13
|
+
:smartypants,
|
14
|
+
].freeze
|
15
|
+
RENDER_OPTIONS = [
|
16
|
+
:GITHUB_PRE_LANG,
|
17
|
+
:HARDBREAKS,
|
18
|
+
:NOBREAKS,
|
19
|
+
:SAFE,
|
20
|
+
:SOURCEPOS,
|
21
|
+
].freeze
|
22
|
+
EXTENSIONS = [
|
23
|
+
:autolink,
|
24
|
+
:strikethrough,
|
25
|
+
:table,
|
26
|
+
:tagfilter,
|
27
|
+
].freeze
|
28
|
+
|
29
|
+
def extensions
|
30
|
+
EXTENSIONS.select do |extension|
|
31
|
+
options[extension]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def parse_options
|
36
|
+
raw_options = PARSE_OPTIONS.select do |option|
|
37
|
+
options[option]
|
38
|
+
end
|
39
|
+
actual_options = raw_options.map do |option|
|
40
|
+
OPTION_ALIAS[option] || option
|
41
|
+
end
|
42
|
+
|
43
|
+
if actual_options.any?
|
44
|
+
actual_options
|
45
|
+
else
|
46
|
+
:DEFAULT
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def render_options
|
51
|
+
raw_options = RENDER_OPTIONS.select do |option|
|
52
|
+
options[option]
|
53
|
+
end
|
54
|
+
actual_options = raw_options.map do |option|
|
55
|
+
OPTION_ALIAS[option] || option
|
56
|
+
end
|
57
|
+
if actual_options.any?
|
58
|
+
actual_options
|
59
|
+
else
|
60
|
+
:DEFAULT
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
8
64
|
def prepare
|
9
65
|
@engine = nil
|
10
66
|
@output = nil
|
11
67
|
end
|
12
68
|
|
13
69
|
def evaluate(scope, locals, &block)
|
14
|
-
CommonMarker.
|
70
|
+
doc = CommonMarker.render_doc(data, parse_options, extensions)
|
71
|
+
doc.to_html(render_options, extensions)
|
15
72
|
end
|
16
73
|
|
17
74
|
def allows_script?
|
data/lib/tilt/erb.rb
CHANGED
@@ -7,6 +7,8 @@ module Tilt
|
|
7
7
|
class ERBTemplate < Template
|
8
8
|
@@default_output_variable = '_erbout'
|
9
9
|
|
10
|
+
SUPPORTS_KVARGS = ::ERB.instance_method(:initialize).parameters.assoc(:key) rescue false
|
11
|
+
|
10
12
|
def self.default_output_variable
|
11
13
|
@@default_output_variable
|
12
14
|
end
|
@@ -19,7 +21,11 @@ module Tilt
|
|
19
21
|
def prepare
|
20
22
|
@outvar = options[:outvar] || self.class.default_output_variable
|
21
23
|
options[:trim] = '<>' if !(options[:trim] == false) && (options[:trim].nil? || options[:trim] == true)
|
22
|
-
@engine =
|
24
|
+
@engine = if SUPPORTS_KVARGS
|
25
|
+
::ERB.new(data, trim_mode: options[:trim], eoutvar: @outvar)
|
26
|
+
else
|
27
|
+
::ERB.new(data, options[:safe], options[:trim], @outvar)
|
28
|
+
end
|
23
29
|
end
|
24
30
|
|
25
31
|
def precompiled_template(locals)
|
data/lib/tilt/haml.rb
CHANGED
@@ -62,7 +62,7 @@ module Tilt
|
|
62
62
|
<<-RUBY
|
63
63
|
begin
|
64
64
|
extend Haml::Helpers
|
65
|
-
_hamlout = @haml_buffer = Haml::Buffer.new(
|
65
|
+
_hamlout = @haml_buffer = Haml::Buffer.new(haml_buffer, #{options_for_buffer.inspect})
|
66
66
|
_erbout = _hamlout.buffer
|
67
67
|
__in_erb_template = true
|
68
68
|
_haml_locals = locals
|
@@ -76,7 +76,7 @@ module Tilt
|
|
76
76
|
<<-RUBY
|
77
77
|
#{precompiled_method_return_value}
|
78
78
|
ensure
|
79
|
-
@haml_buffer = @haml_buffer.upper if
|
79
|
+
@haml_buffer = @haml_buffer.upper if haml_buffer
|
80
80
|
end
|
81
81
|
RUBY
|
82
82
|
end
|
data/lib/tilt/sass.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'tilt/template'
|
2
|
-
require 'sass'
|
3
2
|
|
4
3
|
module Tilt
|
5
4
|
# Sass template implementation. See:
|
@@ -9,8 +8,20 @@ module Tilt
|
|
9
8
|
class SassTemplate < Template
|
10
9
|
self.default_mime_type = 'text/css'
|
11
10
|
|
11
|
+
begin
|
12
|
+
require 'sassc'
|
13
|
+
Sass = ::SassC
|
14
|
+
rescue LoadError => err
|
15
|
+
begin
|
16
|
+
require 'sass'
|
17
|
+
Sass = ::Sass
|
18
|
+
rescue LoadError
|
19
|
+
raise err
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
12
23
|
def prepare
|
13
|
-
@engine =
|
24
|
+
@engine = Sass::Engine.new(data, sass_options)
|
14
25
|
end
|
15
26
|
|
16
27
|
def evaluate(scope, locals, &block)
|
@@ -14,6 +14,14 @@ begin
|
|
14
14
|
template = Tilt::CommonMarkerTemplate.new { |t| "# Hello World!" }
|
15
15
|
3.times { assert_equal "<h1>Hello World!</h1>\n", template.render }
|
16
16
|
end
|
17
|
+
|
18
|
+
test "smartypants when :smartypants is set" do
|
19
|
+
template = Tilt::CommonMarkerTemplate.new(:smartypants => true) do |t|
|
20
|
+
"OKAY -- 'Smarty Pants'"
|
21
|
+
end
|
22
|
+
assert_match('<p>OKAY – ‘Smarty Pants’</p>', template.render)
|
23
|
+
end
|
24
|
+
|
17
25
|
end
|
18
26
|
rescue LoadError
|
19
27
|
warn "Tilt::CommonMarkerTemplate (disabled)"
|
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 = '
|
6
|
+
s.version = '2.0.9'
|
7
|
+
s.date = '2018-11-28'
|
8
8
|
|
9
9
|
s.description = "Generic interface to multiple Ruby template engines"
|
10
10
|
s.summary = s.description
|
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.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Tomayko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Generic interface to multiple Ruby template engines
|
14
14
|
email: r@tomayko.com
|