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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d73cf811e4d1767fcb602eef69ec1d957eb72919
4
- data.tar.gz: 30723694d8d6d8f45d1b073d3cd1403358636414
3
+ metadata.gz: 628b7587af284142a071a75dec94e684b6972d16
4
+ data.tar.gz: a686e34c2f8d764a74e2760fe5af2fc22c27b66d
5
5
  SHA512:
6
- metadata.gz: 1b94f99935c3135724349c3f6ff87f22b4dea1569b0be12624c5f7728721b10587c924030d176d3b53ad54a087acc683556ab47983ed0eb1ba3ab960c4ea1898
7
- data.tar.gz: 84ea12c485ab60ad8255dfb2a5b26ac4879353290219346de4ac3351b9049ef79bdba3e00380009d9ca0e513edc3c9abf5437b17c0a22d051c4c5946b06db5ab
6
+ metadata.gz: b802450ebc32e4d50d65af2bf827bf8e6b92d85787ea9507701d70e6c0e8df911fce4402e53e99e95029d11daa4bcbca6ed99f5c90fa0235d0051d7a290a6446
7
+ data.tar.gz: a2db67256a1c846deabd6520d943e101645ea25cb610d022e60f2755dbddddfd8197275c6783ed663f569538647553714a1151d6d660887caf8ae6662b008159
@@ -1,5 +1,10 @@
1
1
  ## master
2
2
 
3
+ ## 2.0.9 (2018-11-28)
4
+
5
+ * Use new ERB API in Ruby 2.6 (#329, koic)
6
+ * Support the new sassc gem (#336, jdickey, judofyr)
7
+
3
8
  ## 2.0.8 (2017-07-24)
4
9
 
5
10
  * Register .tsx for TypeScript (#315, backus)
data/Gemfile CHANGED
@@ -17,7 +17,12 @@ group :primary do
17
17
  gem 'haml', '>= 4' if RUBY_VERSION >= '2.0.0'
18
18
  gem 'erubis'
19
19
  gem 'markaby'
20
- gem 'sass'
20
+
21
+ if ENV['OLD_SASS']
22
+ gem 'sass'
23
+ else
24
+ gem 'sassc'
25
+ end
21
26
 
22
27
  if can_execjs
23
28
  gem 'less'
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) [![Dependency Status](https://gemnasium.com/rtomayko/tilt.svg)](https://gemnasium.com/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)
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
@@ -10,7 +10,7 @@ desc 'Run tests (default)'
10
10
  Rake::TestTask.new(:test) do |t|
11
11
  t.test_files = FileList['test/*_test.rb']
12
12
  t.ruby_opts = ['-Itest']
13
- t.ruby_opts << '-rubygems' if defined? Gem
13
+ t.ruby_opts << '-rrubygems' if defined? Gem
14
14
  t.warning = false
15
15
  end
16
16
 
@@ -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.8'
7
+ VERSION = '2.0.9'
8
8
 
9
9
  @default_mapping = Mapping.new
10
10
 
@@ -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.render_html(data, :DEFAULT)
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?
@@ -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 = ::ERB.new(data, options[:safe], options[:trim], @outvar)
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)
@@ -62,7 +62,7 @@ module Tilt
62
62
  <<-RUBY
63
63
  begin
64
64
  extend Haml::Helpers
65
- _hamlout = @haml_buffer = Haml::Buffer.new(@haml_buffer, #{options_for_buffer.inspect})
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 @haml_buffer
79
+ @haml_buffer = @haml_buffer.upper if haml_buffer
80
80
  end
81
81
  RUBY
82
82
  end
@@ -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 = ::Sass::Engine.new(data, sass_options)
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)"
@@ -36,6 +36,7 @@ begin
36
36
  end
37
37
  end
38
38
 
39
- rescue LoadError
39
+ rescue LoadError => err
40
+ raise err if ENV['FORCE_SASS']
40
41
  warn "Tilt::SassTemplate (disabled)"
41
42
  end
@@ -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.8'
7
- s.date = '2017-07-24'
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.8
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: 2017-07-24 00:00:00.000000000 Z
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