hamlit 2.9.4-java → 2.12.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +12 -10
- data/CHANGELOG.md +45 -0
- data/Gemfile +2 -8
- data/REFERENCE.md +13 -4
- data/benchmark/dynamic_merger/benchmark.rb +25 -0
- data/benchmark/dynamic_merger/hello.haml +50 -0
- data/benchmark/dynamic_merger/hello.string +50 -0
- data/bin/bench +3 -3
- data/ext/hamlit/hamlit.c +0 -1
- data/hamlit.gemspec +3 -1
- data/lib/hamlit/attribute_builder.rb +2 -2
- data/lib/hamlit/attribute_compiler.rb +3 -3
- data/lib/hamlit/compiler/children_compiler.rb +18 -4
- data/lib/hamlit/compiler/comment_compiler.rb +7 -5
- data/lib/hamlit/compiler/tag_compiler.rb +0 -4
- data/lib/hamlit/dynamic_merger.rb +67 -0
- data/lib/hamlit/engine.rb +5 -6
- data/lib/hamlit/filters/plain.rb +0 -3
- data/lib/hamlit/html.rb +8 -0
- data/lib/hamlit/parser/haml_attribute_builder.rb +164 -0
- data/lib/hamlit/parser/haml_helpers.rb +6 -0
- data/lib/hamlit/parser/haml_parser.rb +32 -9
- data/lib/hamlit/parser/haml_xss_mods.rb +6 -3
- data/lib/hamlit/string_splitter.rb +9 -78
- data/lib/hamlit/template.rb +1 -1
- data/lib/hamlit/temple_line_counter.rb +31 -0
- data/lib/hamlit/version.rb +1 -1
- metadata +53 -21
- data/lib/hamlit/hamlit.su +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9730ad24ae51f479f990d08aaa054adc41541e02f058889d085c437b7fce3772
|
4
|
+
data.tar.gz: 96956fc4d9e69332956936769d0843548d769179f31c2499706befc566dab02b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d12567ab91773b31fbb8431362c821261b5ad47e678f75465df51e52a48bb101da829dd9e93b7aea75925a77b179f09f92ab08c0c0042b46478f0497bed7c6e
|
7
|
+
data.tar.gz: fa594a116affab20ea90313253bc5308a9e0d47a369b07d4b971e97728ac8fcbb6bbaa4ee1509ffede4b9f546e47d1abd6810d0c545377357748805416bfd34f
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -9,11 +9,13 @@ matrix:
|
|
9
9
|
include:
|
10
10
|
- rvm: 2.3.8
|
11
11
|
env: TASK=test
|
12
|
-
- rvm: 2.4.
|
12
|
+
- rvm: 2.4.9
|
13
13
|
env: TASK=test
|
14
|
-
- rvm: 2.5.
|
14
|
+
- rvm: 2.5.7
|
15
15
|
env: TASK=test
|
16
|
-
- rvm: 2.6.
|
16
|
+
- rvm: 2.6.5
|
17
|
+
env: TASK=test
|
18
|
+
- rvm: 2.7.0
|
17
19
|
env: TASK=test
|
18
20
|
- rvm: ruby-head
|
19
21
|
env: TASK=test
|
@@ -21,19 +23,19 @@ matrix:
|
|
21
23
|
env: TASK=test
|
22
24
|
- rvm: truffleruby
|
23
25
|
env: TASK=test
|
24
|
-
- rvm: 2.
|
26
|
+
- rvm: 2.7.0
|
25
27
|
env: TASK=bench TEMPLATE=benchmark/boolean_attribute.haml,benchmark/class_attribute.haml,benchmark/id_attribute.haml,benchmark/data_attribute.haml,benchmark/common_attribute.haml
|
26
|
-
- rvm: 2.
|
28
|
+
- rvm: 2.7.0
|
27
29
|
env: TASK=bench TEMPLATE=benchmark/dynamic_attributes/boolean_attribute.haml,benchmark/dynamic_attributes/class_attribute.haml,benchmark/dynamic_attributes/id_attribute.haml,benchmark/dynamic_attributes/data_attribute.haml,benchmark/dynamic_attributes/common_attribute.haml
|
28
|
-
- rvm: 2.
|
30
|
+
- rvm: 2.7.0
|
29
31
|
env: TASK=bench SLIM_BENCH=1
|
30
|
-
- rvm: 2.
|
32
|
+
- rvm: 2.7.0
|
31
33
|
env: TASK=bench TEMPLATE=benchmark/etc/attribute_builder.haml
|
32
|
-
- rvm: 2.
|
34
|
+
- rvm: 2.7.0
|
33
35
|
env: TASK=bench TEMPLATE=benchmark/etc/static_analyzer.haml
|
34
|
-
- rvm: 2.
|
36
|
+
- rvm: 2.7.0
|
35
37
|
env: TASK=bench TEMPLATE=benchmark/etc/string_interpolation.haml
|
36
|
-
- rvm: 2.
|
38
|
+
- rvm: 2.7.0
|
37
39
|
env: TASK=bench TEMPLATE=test/haml/templates/standard.haml COMPILE=1
|
38
40
|
allow_failures:
|
39
41
|
- rvm: ruby-head
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,51 @@ All notable changes to this project will be documented in this file. This
|
|
4
4
|
project adheres to [Semantic Versioning](http://semver.org/). This change log is based upon
|
5
5
|
[keep-a-changelog](https://github.com/olivierlacan/keep-a-changelog).
|
6
6
|
|
7
|
+
## [2.12.0](https://github.com/k0kubun/hamlit/compare/v2.11.1...v2.12.0) - 2020-09-30
|
8
|
+
|
9
|
+
### Changed
|
10
|
+
|
11
|
+
- Class names are no longer ordered alphabetically
|
12
|
+
*Thanks to @aliismayilov*
|
13
|
+
- This is compatible with [Haml 5.2](https://github.com/haml/haml/blob/v5.2.0/CHANGELOG.md#52)
|
14
|
+
|
15
|
+
## [2.11.1](https://github.com/k0kubun/hamlit/compare/v2.11.0...v2.11.1) - 2020-08-25
|
16
|
+
|
17
|
+
### Fixed
|
18
|
+
|
19
|
+
- Fix a line number on an error after filters like preserve, plain, and ruby.
|
20
|
+
*Thanks to @rgisiger*
|
21
|
+
|
22
|
+
## [2.11.0](https://github.com/k0kubun/hamlit/compare/v2.10.1...v2.11.0) - 2019-12-12
|
23
|
+
|
24
|
+
### Added
|
25
|
+
|
26
|
+
- Support Haml's _revealed_ conditional comment feature on `/![if !IE]` [#153](https://github.com/k0kubun/hamlit/issues/153).
|
27
|
+
*Thanks to @esb*
|
28
|
+
|
29
|
+
## [2.10.1](https://github.com/k0kubun/hamlit/compare/v2.10.0...v2.10.1) - 2019-11-28
|
30
|
+
|
31
|
+
### Added
|
32
|
+
|
33
|
+
- Register `Hamlit::Template` to Tilt as :hamlit as well, in addition to :haml
|
34
|
+
|
35
|
+
## [2.10.0](https://github.com/k0kubun/hamlit/compare/v2.9.5...v2.10.0) - 2019-09-15
|
36
|
+
|
37
|
+
### Added
|
38
|
+
|
39
|
+
- Optimize template rendering by string interpolation [#146](https://github.com/k0kubun/hamlit/issues/146)
|
40
|
+
- Exploiting pre-allocation of string interpolation introduced in Ruby 2.5 [ruby/ruby#1626](https://github.com/ruby/ruby/pull/1626)
|
41
|
+
|
42
|
+
### Changed
|
43
|
+
|
44
|
+
- Require temple.gem >= 0.8.2
|
45
|
+
|
46
|
+
## [2.9.5](https://github.com/k0kubun/hamlit/compare/v2.9.4...v2.9.5) - 2019-09-08
|
47
|
+
|
48
|
+
### Added
|
49
|
+
|
50
|
+
- Supported `:plain` filter in truffleruby
|
51
|
+
|
7
52
|
## [2.9.4](https://github.com/k0kubun/hamlit/compare/v2.9.3...v2.9.4) - 2019-09-08
|
8
53
|
|
9
54
|
### Added
|
data/Gemfile
CHANGED
@@ -8,23 +8,17 @@ end
|
|
8
8
|
# Specify your gem's dependencies in hamlit.gemspec
|
9
9
|
gemspec
|
10
10
|
|
11
|
-
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.2.2')
|
12
|
-
gem 'rack', '< 2'
|
13
|
-
end
|
14
|
-
|
15
11
|
gem 'benchmark-ips', '2.3.0'
|
16
12
|
gem 'maxitest'
|
13
|
+
gem 'pry'
|
17
14
|
|
18
15
|
if /java/ === RUBY_PLATFORM # JRuby
|
19
16
|
gem 'pandoc-ruby'
|
20
17
|
else
|
21
|
-
gem 'pry-byebug'
|
22
18
|
gem 'redcarpet'
|
23
19
|
|
24
20
|
if RUBY_PLATFORM !~ /mswin|mingw/ && RUBY_ENGINE != 'truffleruby'
|
25
|
-
|
26
|
-
gem 'faml'
|
27
|
-
end
|
21
|
+
gem 'faml'
|
28
22
|
gem 'stackprof'
|
29
23
|
end
|
30
24
|
end
|
data/REFERENCE.md
CHANGED
@@ -57,6 +57,7 @@ for full features in original implementation.
|
|
57
57
|
- [x] :plain
|
58
58
|
- [x] :preserve
|
59
59
|
- [x] :ruby
|
60
|
+
- `haml_io` API is not supported. Use [hamlit-haml\_io.gem](https://github.com/hamlit/hamlit-haml_io) if you need.
|
60
61
|
- [x] :sass
|
61
62
|
- [x] :scss
|
62
63
|
- [ ] :textile
|
@@ -121,10 +122,10 @@ and merging multiple ids results in concatenation by "\_".
|
|
121
122
|
%div{ id: false }
|
122
123
|
|
123
124
|
# Output
|
124
|
-
<div id='foo_bar'></
|
125
|
-
<div id='foo_bar'></
|
126
|
-
<div id='foo_bar'></
|
127
|
-
<div id=''></
|
125
|
+
<div id='foo_bar'></div>
|
126
|
+
<div id='foo_bar'></div>
|
127
|
+
<div id='foo_bar'></div>
|
128
|
+
<div id=''></div>
|
128
129
|
```
|
129
130
|
|
130
131
|
### class attribute
|
@@ -224,6 +225,14 @@ Hamlit::RailsTemplate.set_options attr_quote: '"'
|
|
224
225
|
set :haml, { attr_quote: '"' }
|
225
226
|
```
|
226
227
|
|
228
|
+
## Ruby module
|
229
|
+
|
230
|
+
`Hamlit::Template` is a module registered to `Tilt`. You can use it like:
|
231
|
+
|
232
|
+
```rb
|
233
|
+
Hamlit::Template.new { "%strong Yay for HAML!" }.render
|
234
|
+
```
|
235
|
+
|
227
236
|
## Creating a custom filter
|
228
237
|
|
229
238
|
Currently it doesn't have filter registering interface compatible with Haml.
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# Original: https://github.com/amatsuda/string_template/blob/master/benchmark.rb
|
2
|
+
require 'benchmark_driver'
|
3
|
+
|
4
|
+
Benchmark.driver(repeat_count: 8) do |x|
|
5
|
+
x.prelude %{
|
6
|
+
require 'rails'
|
7
|
+
require 'action_view'
|
8
|
+
require 'string_template'
|
9
|
+
StringTemplate::Railtie.run_initializers
|
10
|
+
require 'hamlit'
|
11
|
+
Hamlit::Railtie.run_initializers
|
12
|
+
Hamlit::RailsTemplate.set_options(escape_html: false, generator: Temple::Generators::ArrayBuffer)
|
13
|
+
require 'action_view/base'
|
14
|
+
|
15
|
+
(view = Class.new(ActionView::Base).new(ActionView::LookupContext.new(''))).instance_variable_set(:@world, 'world!')
|
16
|
+
|
17
|
+
# compile template
|
18
|
+
hello = 'benchmark/dynamic_merger/hello'
|
19
|
+
view.render(template: hello, handlers: 'string')
|
20
|
+
view.render(template: hello, handlers: 'haml')
|
21
|
+
}
|
22
|
+
x.report 'string', %{ view.render(template: hello, handlers: 'string') }
|
23
|
+
x.report 'hamlit', %{ view.render(template: hello, handlers: 'haml') }
|
24
|
+
x.loop_count 100_000
|
25
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
hello, #{ @world }
|
2
|
+
hello, #{ @world }
|
3
|
+
hello, #{ @world }
|
4
|
+
hello, #{ @world }
|
5
|
+
hello, #{ @world }
|
6
|
+
hello, #{ @world }
|
7
|
+
hello, #{ @world }
|
8
|
+
hello, #{ @world }
|
9
|
+
hello, #{ @world }
|
10
|
+
hello, #{ @world }
|
11
|
+
hello, #{ @world }
|
12
|
+
hello, #{ @world }
|
13
|
+
hello, #{ @world }
|
14
|
+
hello, #{ @world }
|
15
|
+
hello, #{ @world }
|
16
|
+
hello, #{ @world }
|
17
|
+
hello, #{ @world }
|
18
|
+
hello, #{ @world }
|
19
|
+
hello, #{ @world }
|
20
|
+
hello, #{ @world }
|
21
|
+
hello, #{ @world }
|
22
|
+
hello, #{ @world }
|
23
|
+
hello, #{ @world }
|
24
|
+
hello, #{ @world }
|
25
|
+
hello, #{ @world }
|
26
|
+
hello, #{ @world }
|
27
|
+
hello, #{ @world }
|
28
|
+
hello, #{ @world }
|
29
|
+
hello, #{ @world }
|
30
|
+
hello, #{ @world }
|
31
|
+
hello, #{ @world }
|
32
|
+
hello, #{ @world }
|
33
|
+
hello, #{ @world }
|
34
|
+
hello, #{ @world }
|
35
|
+
hello, #{ @world }
|
36
|
+
hello, #{ @world }
|
37
|
+
hello, #{ @world }
|
38
|
+
hello, #{ @world }
|
39
|
+
hello, #{ @world }
|
40
|
+
hello, #{ @world }
|
41
|
+
hello, #{ @world }
|
42
|
+
hello, #{ @world }
|
43
|
+
hello, #{ @world }
|
44
|
+
hello, #{ @world }
|
45
|
+
hello, #{ @world }
|
46
|
+
hello, #{ @world }
|
47
|
+
hello, #{ @world }
|
48
|
+
hello, #{ @world }
|
49
|
+
hello, #{ @world }
|
50
|
+
hello, #{ @world }
|
@@ -0,0 +1,50 @@
|
|
1
|
+
hello, #{ @world }
|
2
|
+
hello, #{ @world }
|
3
|
+
hello, #{ @world }
|
4
|
+
hello, #{ @world }
|
5
|
+
hello, #{ @world }
|
6
|
+
hello, #{ @world }
|
7
|
+
hello, #{ @world }
|
8
|
+
hello, #{ @world }
|
9
|
+
hello, #{ @world }
|
10
|
+
hello, #{ @world }
|
11
|
+
hello, #{ @world }
|
12
|
+
hello, #{ @world }
|
13
|
+
hello, #{ @world }
|
14
|
+
hello, #{ @world }
|
15
|
+
hello, #{ @world }
|
16
|
+
hello, #{ @world }
|
17
|
+
hello, #{ @world }
|
18
|
+
hello, #{ @world }
|
19
|
+
hello, #{ @world }
|
20
|
+
hello, #{ @world }
|
21
|
+
hello, #{ @world }
|
22
|
+
hello, #{ @world }
|
23
|
+
hello, #{ @world }
|
24
|
+
hello, #{ @world }
|
25
|
+
hello, #{ @world }
|
26
|
+
hello, #{ @world }
|
27
|
+
hello, #{ @world }
|
28
|
+
hello, #{ @world }
|
29
|
+
hello, #{ @world }
|
30
|
+
hello, #{ @world }
|
31
|
+
hello, #{ @world }
|
32
|
+
hello, #{ @world }
|
33
|
+
hello, #{ @world }
|
34
|
+
hello, #{ @world }
|
35
|
+
hello, #{ @world }
|
36
|
+
hello, #{ @world }
|
37
|
+
hello, #{ @world }
|
38
|
+
hello, #{ @world }
|
39
|
+
hello, #{ @world }
|
40
|
+
hello, #{ @world }
|
41
|
+
hello, #{ @world }
|
42
|
+
hello, #{ @world }
|
43
|
+
hello, #{ @world }
|
44
|
+
hello, #{ @world }
|
45
|
+
hello, #{ @world }
|
46
|
+
hello, #{ @world }
|
47
|
+
hello, #{ @world }
|
48
|
+
hello, #{ @world }
|
49
|
+
hello, #{ @world }
|
50
|
+
hello, #{ @world }
|
data/bin/bench
CHANGED
@@ -25,7 +25,7 @@ class Bench < Thor
|
|
25
25
|
haml = File.read(file)
|
26
26
|
|
27
27
|
Benchmark.ips do |x|
|
28
|
-
x.report("haml v#{Haml::VERSION}") { Haml::Engine.new(haml, escape_html: true, escape_attrs: true
|
28
|
+
x.report("haml v#{Haml::VERSION}") { Haml::Engine.new(haml, escape_html: true, escape_attrs: true).precompiled }
|
29
29
|
x.report("faml v#{Faml::VERSION}") { Faml::Engine.new.call(haml) }
|
30
30
|
x.report("hamlit v#{Hamlit::VERSION}") { Hamlit::Engine.new.call(haml) }
|
31
31
|
x.compare!
|
@@ -43,7 +43,7 @@ class Bench < Thor
|
|
43
43
|
object.instance_eval(File.read(ruby_file))
|
44
44
|
end
|
45
45
|
|
46
|
-
Haml::Engine.new(haml, escape_html: true, escape_attrs: true
|
46
|
+
Haml::Engine.new(haml, escape_html: true, escape_attrs: true).def_method(object, :haml)
|
47
47
|
object.instance_eval "def faml; #{Faml::Engine.new.call(haml)}; end"
|
48
48
|
object.instance_eval "def hamlit; #{Hamlit::Engine.new.call(haml)}; end"
|
49
49
|
|
@@ -59,7 +59,7 @@ class Bench < Thor
|
|
59
59
|
def code(file)
|
60
60
|
haml = File.read(file)
|
61
61
|
puts "#{?= * 49}\n Haml Source: #{file}\n#{?= * 49}"
|
62
|
-
puts Haml::Engine.new(haml, escape_html: true, escape_attrs: true
|
62
|
+
puts Haml::Engine.new(haml, escape_html: true, escape_attrs: true).precompiled
|
63
63
|
puts "\n#{?= * 49}\n Faml Source: #{file}\n#{?= * 49}"
|
64
64
|
puts Faml::Engine.new.call(haml)
|
65
65
|
puts "\n#{?= * 49}\n Hamlit Source: #{file}\n#{?= * 49}"
|
data/ext/hamlit/hamlit.c
CHANGED
data/hamlit.gemspec
CHANGED
@@ -26,10 +26,11 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.required_ruby_version = '>= 2.1.0'
|
27
27
|
end
|
28
28
|
|
29
|
-
spec.add_dependency 'temple', '>= 0.8.
|
29
|
+
spec.add_dependency 'temple', '>= 0.8.2'
|
30
30
|
spec.add_dependency 'thor'
|
31
31
|
spec.add_dependency 'tilt'
|
32
32
|
|
33
|
+
spec.add_development_dependency 'benchmark_driver'
|
33
34
|
spec.add_development_dependency 'bundler'
|
34
35
|
spec.add_development_dependency 'coffee-script'
|
35
36
|
spec.add_development_dependency 'erubi'
|
@@ -41,5 +42,6 @@ Gem::Specification.new do |spec|
|
|
41
42
|
spec.add_development_dependency 'rake-compiler'
|
42
43
|
spec.add_development_dependency 'sass'
|
43
44
|
spec.add_development_dependency 'slim'
|
45
|
+
spec.add_development_dependency 'string_template'
|
44
46
|
spec.add_development_dependency 'unindent'
|
45
47
|
end
|
@@ -47,7 +47,7 @@ module Hamlit::AttributeBuilder
|
|
47
47
|
when value.is_a?(String)
|
48
48
|
# noop
|
49
49
|
when value.is_a?(Array)
|
50
|
-
value = value.flatten.select { |v| v }.map(&:to_s).
|
50
|
+
value = value.flatten.select { |v| v }.map(&:to_s).uniq.join(' ')
|
51
51
|
when value
|
52
52
|
value = value.to_s
|
53
53
|
else
|
@@ -67,7 +67,7 @@ module Hamlit::AttributeBuilder
|
|
67
67
|
classes << value.to_s
|
68
68
|
end
|
69
69
|
end
|
70
|
-
escape_html(escape_attrs, classes.map(&:to_s).
|
70
|
+
escape_html(escape_attrs, classes.map(&:to_s).uniq.join(' '))
|
71
71
|
end
|
72
72
|
|
73
73
|
def build_data(escape_attrs, quote, *hashes)
|
@@ -17,7 +17,7 @@ module Hamlit
|
|
17
17
|
if node.value[:object_ref] != :nil || !Ripper.respond_to?(:lex) # No Ripper.lex in truffleruby
|
18
18
|
return runtime_compile(node)
|
19
19
|
end
|
20
|
-
node.value[:
|
20
|
+
[node.value[:dynamic_attributes].new, node.value[:dynamic_attributes].old].compact.each do |attribute_str|
|
21
21
|
hash = AttributeParser.parse(attribute_str)
|
22
22
|
return runtime_compile(node) unless hash
|
23
23
|
hashes << hash
|
@@ -28,11 +28,11 @@ module Hamlit
|
|
28
28
|
private
|
29
29
|
|
30
30
|
def runtime_compile(node)
|
31
|
-
attrs =
|
31
|
+
attrs = []
|
32
32
|
attrs.unshift(node.value[:attributes].inspect) if node.value[:attributes] != {}
|
33
33
|
|
34
34
|
args = [@escape_attrs.inspect, "#{@quote.inspect}.freeze", @format.inspect].push(node.value[:object_ref]) + attrs
|
35
|
-
[:html, :attrs, [:dynamic, "::Hamlit::AttributeBuilder.build(#{args.join(', ')})"]]
|
35
|
+
[:html, :attrs, [:dynamic, "::Hamlit::AttributeBuilder.build(#{args.join(', ')}, #{node.value[:dynamic_attributes].to_literal})"]]
|
36
36
|
end
|
37
37
|
|
38
38
|
def static_compile(static_hash, dynamic_hashes)
|
@@ -1,4 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
require 'hamlit/temple_line_counter'
|
3
|
+
|
2
4
|
module Hamlit
|
3
5
|
class Compiler
|
4
6
|
class ChildrenCompiler
|
@@ -14,7 +16,7 @@ module Hamlit
|
|
14
16
|
node.children.each do |n|
|
15
17
|
rstrip_whitespace!(temple) if nuke_prev_whitespace?(n)
|
16
18
|
insert_newlines!(temple, n)
|
17
|
-
temple <<
|
19
|
+
temple << moving_lineno(n) { block.call(n) }
|
18
20
|
temple << :whitespace if insert_whitespace?(n)
|
19
21
|
end
|
20
22
|
rstrip_whitespace!(temple) if nuke_inner_whitespace?(node)
|
@@ -27,19 +29,31 @@ module Hamlit
|
|
27
29
|
(node.line - @lineno).times do
|
28
30
|
temple << [:newline]
|
29
31
|
end
|
32
|
+
|
30
33
|
@lineno = node.line
|
34
|
+
end
|
31
35
|
|
36
|
+
def moving_lineno(node, &block)
|
37
|
+
# before: As they may have children, we need to increment lineno before compilation.
|
32
38
|
case node.type
|
33
39
|
when :script, :silent_script
|
34
40
|
@lineno += 1
|
35
|
-
when :filter
|
36
|
-
@lineno += (node.value[:text] || '').split("\n").size
|
37
41
|
when :tag
|
38
|
-
node.value[:
|
42
|
+
[node.value[:dynamic_attributes].new, node.value[:dynamic_attributes].old].compact.each do |attribute_hash|
|
39
43
|
@lineno += attribute_hash.count("\n")
|
40
44
|
end
|
41
45
|
@lineno += 1 if node.children.empty? && node.value[:parse]
|
42
46
|
end
|
47
|
+
|
48
|
+
temple = block.call # compile
|
49
|
+
|
50
|
+
# after: filter may not have children, and for some dynamic filters we can't predict the number of lines.
|
51
|
+
case node.type
|
52
|
+
when :filter
|
53
|
+
@lineno += TempleLineCounter.count_lines(temple)
|
54
|
+
end
|
55
|
+
|
56
|
+
temple
|
43
57
|
end
|
44
58
|
|
45
59
|
def confirm_whitespace(temple)
|