hamlit 2.9.2 → 2.9.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +14 -12
- data/CHANGELOG.md +23 -0
- data/Gemfile +5 -3
- data/README.md +4 -0
- data/REFERENCE.md +7 -1
- data/ext/hamlit/hamlit.c +2 -0
- data/hamlit.gemspec +2 -2
- data/lib/hamlit/attribute_builder.rb +3 -1
- data/lib/hamlit/attribute_compiler.rb +3 -1
- data/lib/hamlit/compiler/script_compiler.rb +4 -0
- data/lib/hamlit/compiler/tag_compiler.rb +8 -2
- data/lib/hamlit/engine.rb +4 -2
- data/lib/hamlit/filters/plain.rb +4 -0
- data/lib/hamlit/hamlit.su +0 -0
- data/lib/hamlit/rails_template.rb +3 -2
- data/lib/hamlit/utils.rb +3 -1
- data/lib/hamlit/version.rb +1 -1
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 818a7688a58be17941aea6ddd21986d58186048882d0672b9f8a586d19a00972
|
4
|
+
data.tar.gz: 22c7eaef6d2fb67fe939c8d861780d4d56affa6df0d478ede2b0beb7da6bf79f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56fa71f1352812b9f98e2042f4f59fb54cb35183ee3ee9c29fd9302293446522bbd5c03e0cd9859fb0d757ec854692e544a4a51e169bb9478da68b251f1059a2
|
7
|
+
data.tar.gz: 564b8282a5a1db7b476d664792d157112fbe5f4d28be48b0d31f89542c084fda0c17f86a2930306c3ed9b599b04e43073e81929488d49b0101a78ed2c336bceb
|
data/.travis.yml
CHANGED
@@ -7,31 +7,33 @@ script:
|
|
7
7
|
- "RUBYOPT='-w' bundle exec rake $TASK"
|
8
8
|
matrix:
|
9
9
|
include:
|
10
|
-
- rvm: 2.
|
10
|
+
- rvm: 2.3.8
|
11
11
|
env: TASK=test
|
12
|
-
- rvm: 2.
|
12
|
+
- rvm: 2.4.5
|
13
13
|
env: TASK=test
|
14
|
-
- rvm: 2.
|
14
|
+
- rvm: 2.5.3
|
15
15
|
env: TASK=test
|
16
|
-
- rvm: 2.
|
16
|
+
- rvm: 2.6.0
|
17
17
|
env: TASK=test
|
18
18
|
- rvm: ruby-head
|
19
19
|
env: TASK=test
|
20
|
-
- rvm: jruby-9.
|
20
|
+
- rvm: jruby-9.2.8.0
|
21
21
|
env: TASK=test
|
22
|
-
- rvm:
|
22
|
+
- rvm: truffleruby
|
23
|
+
env: TASK=test
|
24
|
+
- rvm: 2.6.0
|
23
25
|
env: TASK=bench TEMPLATE=benchmark/boolean_attribute.haml,benchmark/class_attribute.haml,benchmark/id_attribute.haml,benchmark/data_attribute.haml,benchmark/common_attribute.haml
|
24
|
-
- rvm: 2.
|
26
|
+
- rvm: 2.6.0
|
25
27
|
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
|
26
|
-
- rvm: 2.
|
28
|
+
- rvm: 2.6.0
|
27
29
|
env: TASK=bench SLIM_BENCH=1
|
28
|
-
- rvm: 2.
|
30
|
+
- rvm: 2.6.0
|
29
31
|
env: TASK=bench TEMPLATE=benchmark/etc/attribute_builder.haml
|
30
|
-
- rvm: 2.
|
32
|
+
- rvm: 2.6.0
|
31
33
|
env: TASK=bench TEMPLATE=benchmark/etc/static_analyzer.haml
|
32
|
-
- rvm: 2.
|
34
|
+
- rvm: 2.6.0
|
33
35
|
env: TASK=bench TEMPLATE=benchmark/etc/string_interpolation.haml
|
34
|
-
- rvm: 2.
|
36
|
+
- rvm: 2.6.0
|
35
37
|
env: TASK=bench TEMPLATE=test/haml/templates/standard.haml COMPILE=1
|
36
38
|
allow_failures:
|
37
39
|
- rvm: ruby-head
|
data/CHANGELOG.md
CHANGED
@@ -4,13 +4,36 @@ 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.9.5](https://github.com/k0kubun/hamlit/compare/v2.9.4...v2.9.5) - 2019-09-08
|
8
|
+
|
9
|
+
### Added
|
10
|
+
|
11
|
+
- Supported `:plain` filter in truffleruby
|
12
|
+
|
13
|
+
## [2.9.4](https://github.com/k0kubun/hamlit/compare/v2.9.3...v2.9.4) - 2019-09-08
|
14
|
+
|
15
|
+
### Added
|
16
|
+
|
17
|
+
- Experimental support of truffleruby [#145](https://github.com/k0kubun/hamlit/issues/145).
|
18
|
+
|
19
|
+
## [2.9.3](https://github.com/k0kubun/hamlit/compare/v2.9.2...v2.9.3) - 2019-04-09
|
20
|
+
|
21
|
+
### Fixed
|
22
|
+
|
23
|
+
- Fix deprecation warning on Rails 6 [#138](https://github.com/k0kubun/hamlit/issues/138).
|
24
|
+
*Thanks to @r7kamura*
|
25
|
+
|
7
26
|
## [2.9.2](https://github.com/k0kubun/hamlit/compare/v2.9.1...v2.9.2) - 2018-11-30
|
8
27
|
|
28
|
+
### Fixed
|
29
|
+
|
9
30
|
- Fix possible `autoload` failure of dependency [#131](https://github.com/k0kubun/hamlit/issues/131).
|
10
31
|
*Thanks to @wimrijnders*
|
11
32
|
|
12
33
|
## [2.9.1](https://github.com/k0kubun/hamlit/compare/v2.9.0...v2.9.1) - 2018-11-01
|
13
34
|
|
35
|
+
### Added
|
36
|
+
|
14
37
|
- Start supporting JRuby [#100](https://github.com/k0kubun/hamlit/issues/100).
|
15
38
|
|
16
39
|
## [2.9.0](https://github.com/k0kubun/hamlit/compare/v2.8.10...v2.9.0) - 2018-10-16
|
data/Gemfile
CHANGED
@@ -19,10 +19,12 @@ if /java/ === RUBY_PLATFORM # JRuby
|
|
19
19
|
gem 'pandoc-ruby'
|
20
20
|
else
|
21
21
|
gem 'pry-byebug'
|
22
|
-
gem 'redcarpet'
|
22
|
+
gem 'redcarpet'
|
23
23
|
|
24
|
-
if RUBY_PLATFORM !~ /mswin|mingw/
|
25
|
-
|
24
|
+
if RUBY_PLATFORM !~ /mswin|mingw/ && RUBY_ENGINE != 'truffleruby'
|
25
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.7.0') # Travis cannot compile ruby.h with C++
|
26
|
+
gem 'faml'
|
27
|
+
end
|
26
28
|
gem 'stackprof'
|
27
29
|
end
|
28
30
|
end
|
data/README.md
CHANGED
@@ -141,6 +141,10 @@ Please report an issue with following information:
|
|
141
141
|
- Hamlit version
|
142
142
|
- Rails/Sinatra version
|
143
143
|
|
144
|
+
### Coding styles
|
145
|
+
|
146
|
+
Please follow the existing coding styles and do not send patches including cosmetic changes.
|
147
|
+
|
144
148
|
## License
|
145
149
|
|
146
150
|
Copyright (c) 2015 Takashi Kokubun
|
data/REFERENCE.md
CHANGED
@@ -99,6 +99,9 @@ Hamlit does not remove non-boolean attributes and render `<a foo=''></a>`
|
|
99
99
|
(`foo` is not removed). This design allows us to reduce string concatenation and
|
100
100
|
is the only difference between Faml and Hamlit.
|
101
101
|
|
102
|
+
You may be also interested in
|
103
|
+
[hamlit/hamlit-boolean\_attributes](https://github.com/hamlit/hamlit-boolean_attributes).
|
104
|
+
|
102
105
|
## 5 Types of Attributes
|
103
106
|
|
104
107
|
Haml has 3 types of attributes: id, class and others.
|
@@ -181,7 +184,10 @@ defer reversed ismap seamless muted required autofocus novalidate formnovalidate
|
|
181
184
|
itemscope allowfullscreen default inert sortable truespeed typemustmatch
|
182
185
|
```
|
183
186
|
|
184
|
-
|
187
|
+
If you want to customize the list of boolean attributes, you can use
|
188
|
+
[hamlit/hamlit-boolean\_attributes](https://github.com/hamlit/hamlit-boolean_attributes).
|
189
|
+
|
190
|
+
"aria-\*" and "data-\*" are also regarded as boolean.
|
185
191
|
|
186
192
|
### other attributes
|
187
193
|
No hyphenation and boolean support. `false` is rendered as "false" (like Rails helpers).
|
data/ext/hamlit/hamlit.c
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
#include <ruby.h>
|
2
2
|
#include <ruby/encoding.h>
|
3
|
+
#ifndef TRUFFLERUBY
|
3
4
|
#include "hescape.h"
|
4
5
|
#include "string.h"
|
5
6
|
|
@@ -551,3 +552,4 @@ Init_hamlit(void)
|
|
551
552
|
rb_const_set(mAttributeBuilder, id_space, rb_obj_freeze(rb_str_new_cstr(" ")));
|
552
553
|
rb_const_set(mAttributeBuilder, id_underscore, rb_obj_freeze(rb_str_new_cstr("_")));
|
553
554
|
}
|
555
|
+
#endif
|
data/hamlit.gemspec
CHANGED
@@ -33,11 +33,11 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.add_development_dependency 'bundler'
|
34
34
|
spec.add_development_dependency 'coffee-script'
|
35
35
|
spec.add_development_dependency 'erubi'
|
36
|
-
spec.add_development_dependency 'haml'
|
36
|
+
spec.add_development_dependency 'haml', '>= 5'
|
37
37
|
spec.add_development_dependency 'less'
|
38
38
|
spec.add_development_dependency 'minitest-reporters', '~> 1.1'
|
39
39
|
spec.add_development_dependency 'rails', '>= 4.0.0'
|
40
|
-
spec.add_development_dependency 'rake'
|
40
|
+
spec.add_development_dependency 'rake'
|
41
41
|
spec.add_development_dependency 'rake-compiler'
|
42
42
|
spec.add_development_dependency 'sass'
|
43
43
|
spec.add_development_dependency 'slim'
|
@@ -9,7 +9,9 @@ module Hamlit::AttributeBuilder
|
|
9
9
|
itemscope allowfullscreen default inert sortable
|
10
10
|
truespeed typemustmatch download].freeze
|
11
11
|
|
12
|
-
|
12
|
+
# Java extension is not implemented for JRuby yet.
|
13
|
+
# TruffleRuby does not implement `rb_ary_sort_bang`, etc.
|
14
|
+
if /java/ === RUBY_PLATFORM || RUBY_ENGINE == 'truffleruby'
|
13
15
|
class << self
|
14
16
|
def build(escape_attrs, quote, format, object_ref, *hashes)
|
15
17
|
hashes << Hamlit::ObjectRef.parse(object_ref) if object_ref
|
@@ -14,7 +14,9 @@ module Hamlit
|
|
14
14
|
|
15
15
|
def compile(node)
|
16
16
|
hashes = []
|
17
|
-
|
17
|
+
if node.value[:object_ref] != :nil || !Ripper.respond_to?(:lex) # No Ripper.lex in truffleruby
|
18
|
+
return runtime_compile(node)
|
19
|
+
end
|
18
20
|
node.value[:attributes_hashes].each do |attribute_str|
|
19
21
|
hash = AttributeParser.parse(attribute_str)
|
20
22
|
return runtime_compile(node) unless hash
|
@@ -11,6 +11,10 @@ module Hamlit
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def compile(node, &block)
|
14
|
+
unless Ripper.respond_to?(:lex) # No Ripper.lex in truffleruby
|
15
|
+
return dynamic_compile(node, &block)
|
16
|
+
end
|
17
|
+
|
14
18
|
no_children = node.children.empty?
|
15
19
|
case
|
16
20
|
when no_children && node.value[:escape_interpolation]
|
@@ -28,8 +28,10 @@ module Hamlit
|
|
28
28
|
nil
|
29
29
|
when node.value[:parse]
|
30
30
|
return compile_interpolated_plain(node) if node.value[:escape_interpolation]
|
31
|
-
|
32
|
-
|
31
|
+
if Ripper.respond_to?(:lex) # No Ripper.lex in truffleruby
|
32
|
+
return delegate_optimization(node) if RubyExpression.string_literal?(node.value[:value])
|
33
|
+
return delegate_optimization(node) if Temple::StaticAnalyzer.static?(node.value[:value])
|
34
|
+
end
|
33
35
|
|
34
36
|
var = @identity.generate
|
35
37
|
[:multi,
|
@@ -53,6 +55,10 @@ module Hamlit
|
|
53
55
|
|
54
56
|
# We should handle interpolation here to escape only interpolated values.
|
55
57
|
def compile_interpolated_plain(node)
|
58
|
+
unless Ripper.respond_to?(:lex) # No Ripper.lex in truffleruby
|
59
|
+
return [:multi, [:escape, node.value[:escape_interpolation], [:dynamic, "%Q[#{node.value[:value]}]"]], [:newline]]
|
60
|
+
end
|
61
|
+
|
56
62
|
temple = [:multi]
|
57
63
|
StringSplitter.compile(node.value[:value]).each do |type, value|
|
58
64
|
case type
|
data/lib/hamlit/engine.rb
CHANGED
@@ -25,8 +25,10 @@ module Hamlit
|
|
25
25
|
use Parser
|
26
26
|
use Compiler
|
27
27
|
use HTML
|
28
|
-
|
29
|
-
|
28
|
+
if Ripper.respond_to?(:lex) # No Ripper.lex in truffleruby
|
29
|
+
use StringSplitter
|
30
|
+
filter :StaticAnalyzer
|
31
|
+
end
|
30
32
|
use Escapable
|
31
33
|
use ForceEscapable
|
32
34
|
filter :ControlFlow
|
data/lib/hamlit/filters/plain.rb
CHANGED
@@ -14,6 +14,10 @@ module Hamlit
|
|
14
14
|
|
15
15
|
def compile_plain(text)
|
16
16
|
string_literal = ::Hamlit::HamlUtil.unescape_interpolation(text)
|
17
|
+
unless Ripper.respond_to?(:lex) # truffleruby doesn't have Ripper.lex
|
18
|
+
return [[:escape, false, [:dynamic, string_literal]]]
|
19
|
+
end
|
20
|
+
|
17
21
|
StringSplitter.compile(string_literal).map do |temple|
|
18
22
|
type, str = temple
|
19
23
|
case type
|
Binary file
|
@@ -23,7 +23,8 @@ module Hamlit
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
def call(template)
|
26
|
+
def call(template, source = nil)
|
27
|
+
source ||= template.source
|
27
28
|
options = RailsTemplate.options
|
28
29
|
|
29
30
|
# https://github.com/haml/haml/blob/4.0.7/lib/haml/template/plugin.rb#L19-L20
|
@@ -32,7 +33,7 @@ module Hamlit
|
|
32
33
|
options = options.merge(format: :xhtml)
|
33
34
|
end
|
34
35
|
|
35
|
-
Engine.new(options).call(
|
36
|
+
Engine.new(options).call(source)
|
36
37
|
end
|
37
38
|
|
38
39
|
def supports_streaming?
|
data/lib/hamlit/utils.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Hamlit
|
3
3
|
module Utils
|
4
|
-
|
4
|
+
# Java extension is not implemented for JRuby yet.
|
5
|
+
# TruffleRuby does not implement `rb_ary_sort_bang`, etc.
|
6
|
+
if /java/ === RUBY_PLATFORM || RUBY_ENGINE == 'truffleruby'
|
5
7
|
require 'cgi/escape'
|
6
8
|
|
7
9
|
def self.escape_html(html)
|
data/lib/hamlit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hamlit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.9.
|
4
|
+
version: 2.9.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takashi Kokubun
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: temple
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '5'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '5'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: less
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -154,16 +154,16 @@ dependencies:
|
|
154
154
|
name: rake
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
|
-
- - "
|
157
|
+
- - ">="
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: '
|
159
|
+
version: '0'
|
160
160
|
type: :development
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
|
-
- - "
|
164
|
+
- - ">="
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: '
|
166
|
+
version: '0'
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: rake-compiler
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -311,6 +311,7 @@ files:
|
|
311
311
|
- lib/hamlit/filters/text_base.rb
|
312
312
|
- lib/hamlit/filters/tilt_base.rb
|
313
313
|
- lib/hamlit/force_escapable.rb
|
314
|
+
- lib/hamlit/hamlit.su
|
314
315
|
- lib/hamlit/helpers.rb
|
315
316
|
- lib/hamlit/html.rb
|
316
317
|
- lib/hamlit/identity.rb
|
@@ -353,8 +354,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
353
354
|
- !ruby/object:Gem::Version
|
354
355
|
version: '0'
|
355
356
|
requirements: []
|
356
|
-
|
357
|
-
rubygems_version: 2.7.6
|
357
|
+
rubygems_version: 3.0.3
|
358
358
|
signing_key:
|
359
359
|
specification_version: 4
|
360
360
|
summary: High Performance Haml Implementation
|