tilt 2.0.7 → 2.0.8

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: 979b58759b26a174d4d8bd50a44a1c597e92f382
4
- data.tar.gz: 5debdcfa427c042650217d5596f7e3b8bb4ec5aa
3
+ metadata.gz: d73cf811e4d1767fcb602eef69ec1d957eb72919
4
+ data.tar.gz: 30723694d8d6d8f45d1b073d3cd1403358636414
5
5
  SHA512:
6
- metadata.gz: ec0b3d559111342335705860143350f0e20d004cc7ee680b2ef5a77c3e93ee57f2ddca4487946b52ad753882d2d96aafe0182a91c0b4d1eecf0f823829319448
7
- data.tar.gz: b4ea47644310701876f05cf06950a0e264d04581f5316c3b6b23d076a0dd3c22550928fa863bce89afa88b8b18219b6820cfda21745778a86bb3d4235b2197e3
6
+ metadata.gz: 1b94f99935c3135724349c3f6ff87f22b4dea1569b0be12624c5f7728721b10587c924030d176d3b53ad54a087acc683556ab47983ed0eb1ba3ab960c4ea1898
7
+ data.tar.gz: 84ea12c485ab60ad8255dfb2a5b26ac4879353290219346de4ac3351b9049ef79bdba3e00380009d9ca0e513edc3c9abf5437b17c0a22d051c4c5946b06db5ab
@@ -1,3 +1,13 @@
1
+ ## master
2
+
3
+ ## 2.0.8 (2017-07-24)
4
+
5
+ * Register .tsx for TypeScript (#315, backus)
6
+ * Use Haml 5's new API (#312, k0kubun)
7
+ * Use correct parser options for CommonMarker (#320, rewritten)
8
+ * Suppress warnings when no locals are used (#304, amatsuda)
9
+ * Haml: Accept `outvar` (#317, k0kubun)
10
+
1
11
  ## 2.0.7 (2017-03-19)
2
12
 
3
13
  * Do not modify BasicObject during template compilation on ruby 2.0+ (#309, jeremyevans)
data/Gemfile CHANGED
@@ -1,5 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ gemspec
4
+
3
5
  gem 'rake'
4
6
  gem 'minitest', '~> 5.0'
5
7
 
@@ -12,7 +14,7 @@ can_execjs = (RUBY_VERSION >= '1.9.3')
12
14
 
13
15
  group :primary do
14
16
  gem 'builder'
15
- gem 'haml', '>= 2.2.11', '< 4'
17
+ gem 'haml', '>= 4' if RUBY_VERSION >= '2.0.0'
16
18
  gem 'erubis'
17
19
  gem 'markaby'
18
20
  gem 'sass'
@@ -61,7 +63,3 @@ group :secondary do
61
63
  end
62
64
  end
63
65
 
64
- ## WHY do I have to do this?!?
65
- platform :rbx do
66
- gem 'rubysl'
67
- end
@@ -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'
7
+ VERSION = '2.0.8'
8
8
 
9
9
  @default_mapping = Mapping.new
10
10
 
@@ -153,7 +153,7 @@ module Tilt
153
153
  register_lazy :ScssTemplate, 'tilt/sass', 'scss'
154
154
  register_lazy :SigilTemplate, 'tilt/sigil', 'sigil'
155
155
  register_lazy :StringTemplate, 'tilt/string', 'str'
156
- register_lazy :TypeScriptTemplate, 'tilt/typescript', 'ts'
156
+ register_lazy :TypeScriptTemplate, 'tilt/typescript', 'ts', 'tsx'
157
157
  register_lazy :WikiClothTemplate, 'tilt/wikicloth', 'wiki', 'mediawiki', 'mw'
158
158
  register_lazy :YajlTemplate, 'tilt/yajl', 'yajl'
159
159
 
@@ -11,7 +11,7 @@ module Tilt
11
11
  end
12
12
 
13
13
  def evaluate(scope, locals, &block)
14
- CommonMarker.render_html(data, :default)
14
+ CommonMarker.render_html(data, :DEFAULT)
15
15
  end
16
16
 
17
17
  def allows_script?
@@ -7,51 +7,79 @@ module Tilt
7
7
  class HamlTemplate < Template
8
8
  self.default_mime_type = 'text/html'
9
9
 
10
- def prepare
11
- options = @options.merge(:filename => eval_file, :line => line)
12
- @engine = ::Haml::Engine.new(data, options)
13
- end
14
-
15
- def evaluate(scope, locals, &block)
16
- raise ArgumentError, 'invalid scope: must not be frozen' if scope.frozen?
10
+ # `Gem::Version.correct?` may return false because of Haml::VERSION #=> "3.1.8 (Separated Sally)". After Haml 4, it's always correct.
11
+ if Gem::Version.correct?(Haml::VERSION) && Gem::Version.new(Haml::VERSION) >= Gem::Version.new('5.0.0.beta.2')
12
+ def prepare
13
+ options = {}.update(@options).update(filename: eval_file, line: line)
14
+ if options.include?(:outvar)
15
+ options[:buffer] = options.delete(:outvar)
16
+ options[:save_buffer] = true
17
+ end
18
+ @engine = ::Haml::TempleEngine.new(options)
19
+ @engine.compile(data)
20
+ end
17
21
 
18
- if @engine.respond_to?(:precompiled_method_return_value, true)
22
+ def evaluate(scope, locals, &block)
23
+ raise ArgumentError, 'invalid scope: must not be frozen' if scope.frozen?
19
24
  super
20
- else
21
- @engine.render(scope, locals, &block)
22
25
  end
23
- end
24
26
 
25
- # Precompiled Haml source. Taken from the precompiled_with_ambles
26
- # method in Haml::Precompiler:
27
- # http://github.com/nex3/haml/blob/master/lib/haml/precompiler.rb#L111-126
28
- def precompiled_template(locals)
29
- @engine.precompiled
30
- end
31
-
32
- def precompiled_preamble(locals)
33
- local_assigns = super
34
- @engine.instance_eval do
35
- <<-RUBY
36
- begin
37
- extend Haml::Helpers
38
- _hamlout = @haml_buffer = Haml::Buffer.new(@haml_buffer, #{options_for_buffer.inspect})
39
- _erbout = _hamlout.buffer
27
+ def precompiled_template(locals)
28
+ @engine.precompiled_with_ambles(
29
+ [],
30
+ after_preamble: <<-RUBY
40
31
  __in_erb_template = true
41
32
  _haml_locals = locals
42
- #{local_assigns}
43
- RUBY
33
+ RUBY
34
+ )
35
+ end
36
+ else # Following definitions are for Haml <= 4 and deprecated.
37
+ def prepare
38
+ options = @options.merge(:filename => eval_file, :line => line)
39
+ @engine = ::Haml::Engine.new(data, options)
40
+ end
41
+
42
+ def evaluate(scope, locals, &block)
43
+ raise ArgumentError, 'invalid scope: must not be frozen' if scope.frozen?
44
+
45
+ if @engine.respond_to?(:precompiled_method_return_value, true)
46
+ super
47
+ else
48
+ @engine.render(scope, locals, &block)
49
+ end
50
+ end
51
+
52
+ # Precompiled Haml source. Taken from the precompiled_with_ambles
53
+ # method in Haml::Precompiler:
54
+ # http://github.com/nex3/haml/blob/master/lib/haml/precompiler.rb#L111-126
55
+ def precompiled_template(locals)
56
+ @engine.precompiled
57
+ end
58
+
59
+ def precompiled_preamble(locals)
60
+ local_assigns = super
61
+ @engine.instance_eval do
62
+ <<-RUBY
63
+ begin
64
+ extend Haml::Helpers
65
+ _hamlout = @haml_buffer = Haml::Buffer.new(@haml_buffer, #{options_for_buffer.inspect})
66
+ _erbout = _hamlout.buffer
67
+ __in_erb_template = true
68
+ _haml_locals = locals
69
+ #{local_assigns}
70
+ RUBY
71
+ end
44
72
  end
45
- end
46
73
 
47
- def precompiled_postamble(locals)
48
- @engine.instance_eval do
49
- <<-RUBY
50
- #{precompiled_method_return_value}
51
- ensure
52
- @haml_buffer = @haml_buffer.upper if @haml_buffer
53
- end
54
- RUBY
74
+ def precompiled_postamble(locals)
75
+ @engine.instance_eval do
76
+ <<-RUBY
77
+ #{precompiled_method_return_value}
78
+ ensure
79
+ @haml_buffer = @haml_buffer.upper if @haml_buffer
80
+ end
81
+ RUBY
82
+ end
55
83
  end
56
84
  end
57
85
  end
@@ -264,6 +264,7 @@ module Tilt
264
264
  Thread.current[:tilt_vars] = [self, locals]
265
265
  class << self
266
266
  this, locals = Thread.current[:tilt_vars]
267
+ locals = locals
267
268
  this.instance_eval do
268
269
  #{local_code}
269
270
  RUBY
@@ -14,6 +14,10 @@ begin
14
14
  assert_equal Tilt::TypeScriptTemplate, Tilt['test.ts']
15
15
  end
16
16
 
17
+ test "is registered for '.tsx' files" do
18
+ assert_equal Tilt::TypeScriptTemplate, Tilt['test.tsx']
19
+ end
20
+
17
21
  test "compiles and evaluates the template on #render" do
18
22
  template = Tilt::TypeScriptTemplate.new { @ts }
19
23
  assert_match @js, template.render
@@ -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'
7
- s.date = '2017-03-19'
6
+ s.version = '2.0.8'
7
+ s.date = '2017-07-24'
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.7
4
+ version: 2.0.8
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-03-19 00:00:00.000000000 Z
11
+ date: 2017-07-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Generic interface to multiple Ruby template engines
14
14
  email: r@tomayko.com
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
145
  version: '0'
146
146
  requirements: []
147
147
  rubyforge_project:
148
- rubygems_version: 2.6.8
148
+ rubygems_version: 2.6.11
149
149
  signing_key:
150
150
  specification_version: 2
151
151
  summary: Generic interface to multiple Ruby template engines