hamlit 2.14.2 → 2.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/FUNDING.yml +1 -0
- data/.github/workflows/test.yml +11 -7
- data/CHANGELOG.md +34 -0
- data/README.md +0 -1
- data/ext/hamlit/hamlit.c +8 -13
- data/lib/hamlit/ambles.rb +20 -0
- data/lib/hamlit/attribute_builder.rb +2 -2
- data/lib/hamlit/attribute_compiler.rb +4 -1
- data/lib/hamlit/engine.rb +2 -0
- data/lib/hamlit/rails_template.rb +5 -0
- data/lib/hamlit/railtie.rb +6 -1
- data/lib/hamlit/version.rb +1 -1
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46fb5b844211b5c8bc782ee88d23eca02b16f9285609e76447a493aa10ee442c
|
4
|
+
data.tar.gz: b1069d514efd9b06b534ec82b3d524fbfde98e87b7b660af6041b60132b7324e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52c0df95e9916faa1abecd927019d4429e28607fc4096157f6386f981cb2f5e6249e8aaabab0693942f7f31c01d0babcaf4dabea1b4cc92ea0d40b2d2cdf531c
|
7
|
+
data.tar.gz: 5241185ed6759415eaf9a263142a6b937fe316c550a59490964e6d10668e26529d730996fd3443d953216fe2a2d30e9af0f5ad241eea92c9e64cf68af55f82bb
|
data/.github/FUNDING.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
github: k0kubun
|
data/.github/workflows/test.yml
CHANGED
@@ -13,24 +13,28 @@ on:
|
|
13
13
|
jobs:
|
14
14
|
test:
|
15
15
|
runs-on: ubuntu-latest
|
16
|
-
container: ${{ matrix.ruby }}
|
17
16
|
strategy:
|
18
17
|
fail-fast: false
|
19
18
|
matrix:
|
20
19
|
ruby:
|
21
|
-
-
|
22
|
-
-
|
23
|
-
-
|
24
|
-
-
|
25
|
-
|
20
|
+
- '2.5'
|
21
|
+
- '2.6'
|
22
|
+
- '2.7'
|
23
|
+
- '3.0'
|
24
|
+
- jruby
|
25
|
+
- truffleruby-head
|
26
26
|
steps:
|
27
27
|
- uses: actions/checkout@v2
|
28
|
+
- name: Set up Ruby
|
29
|
+
uses: ruby/setup-ruby@v1
|
30
|
+
with:
|
31
|
+
ruby-version: ${{ matrix.ruby }}
|
28
32
|
- uses: actions/cache@v2
|
29
33
|
with:
|
30
34
|
path: vendor/bundle
|
31
35
|
key: ${{ runner.os }}-${{ matrix.ruby }}-gems-${{ hashFiles('**/Gemfile.lock') }}
|
32
36
|
restore-keys: ${{ runner.os }}-gems-
|
33
|
-
- run: apt-get update && apt-get install -y nodejs #
|
37
|
+
- run: sudo apt-get update && sudo apt-get install -y nodejs libxslt-dev # nodejs for execjs, libxslt for TruffleRuby nokogiri
|
34
38
|
- name: bundle install
|
35
39
|
run: bundle config path vendor/bundle && bundle install -j$(nproc) --retry 3
|
36
40
|
- run: bundle exec rake test
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,40 @@ 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.15.0](https://github.com/k0kubun/hamlit/compare/v2.14.6...v2.15.0) - 2021-04-12
|
8
|
+
|
9
|
+
### Added
|
10
|
+
|
11
|
+
- Always use Hamlit when both haml.gem and hamlit.gem are installed in Rails
|
12
|
+
*Thanks to @igor-drozdov*
|
13
|
+
|
14
|
+
## [2.14.6](https://github.com/k0kubun/hamlit/compare/v2.14.5...v2.14.6) - 2021-03-23
|
15
|
+
|
16
|
+
### Fixed
|
17
|
+
|
18
|
+
- Optimize v2.14.5's implementation a little
|
19
|
+
|
20
|
+
## [2.14.5](https://github.com/k0kubun/hamlit/compare/v2.14.4...v2.14.5) - 2021-03-23
|
21
|
+
|
22
|
+
### Added
|
23
|
+
|
24
|
+
- Support `config.action_view.annotate_rendered_view_with_filenames = true` of Rails 6.1
|
25
|
+
*Thanks to @kirin121*
|
26
|
+
|
27
|
+
## [2.14.4](https://github.com/k0kubun/hamlit/compare/v2.14.3...v2.14.4) - 2021-02-01
|
28
|
+
|
29
|
+
### Fixed
|
30
|
+
|
31
|
+
- Prevent another SEGV in a C extension after `GC.compact` [#177](https://github.com/k0kubun/hamlit/issues/177)
|
32
|
+
*Thanks to @stanhu*
|
33
|
+
|
34
|
+
## [2.14.3](https://github.com/k0kubun/hamlit/compare/v2.14.2...v2.14.3) - 2021-01-24
|
35
|
+
|
36
|
+
### Fixed
|
37
|
+
|
38
|
+
- Ensure the Rails initializer is called before `:load_config_initializers` [#176](https://github.com/k0kubun/hamlit/issues/176)
|
39
|
+
*Thanks to @sunny*
|
40
|
+
|
7
41
|
## [2.14.2](https://github.com/k0kubun/hamlit/compare/v2.14.1...v2.14.2) - 2021-01-21
|
8
42
|
|
9
43
|
### Fixed
|
data/README.md
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# Hamlit
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/hamlit.svg)](http://badge.fury.io/rb/hamlit)
|
4
|
-
[![Build Status](https://travis-ci.org/k0kubun/hamlit.svg?branch=master)](https://travis-ci.org/k0kubun/hamlit)
|
5
4
|
[![test](https://github.com/k0kubun/hamlit/workflows/test/badge.svg)](https://github.com/k0kubun/hamlit/actions?query=workflow%3Atest)
|
6
5
|
|
7
6
|
Hamlit is a high performance [Haml](https://github.com/haml/haml) implementation.
|
data/ext/hamlit/hamlit.c
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
VALUE mAttributeBuilder, mObjectRef;
|
8
8
|
static ID id_flatten, id_keys, id_parse, id_prepend, id_tr, id_uniq_bang;
|
9
|
-
static ID
|
9
|
+
static ID id_xhtml;
|
10
10
|
|
11
11
|
static VALUE str_aria, str_data, str_equal, str_hyphen, str_space, str_underscore;
|
12
12
|
|
@@ -342,13 +342,10 @@ merge_all_attrs(VALUE hashes)
|
|
342
342
|
}
|
343
343
|
|
344
344
|
int
|
345
|
-
is_boolean_attribute(VALUE key)
|
345
|
+
is_boolean_attribute(VALUE key, VALUE boolean_attributes)
|
346
346
|
{
|
347
|
-
VALUE boolean_attributes;
|
348
347
|
if (str_eq(rb_str_substr(key, 0, 5), "data-", 5)) return 1;
|
349
348
|
if (str_eq(rb_str_substr(key, 0, 5), "aria-", 5)) return 1;
|
350
|
-
|
351
|
-
boolean_attributes = rb_const_get(mAttributeBuilder, id_boolean_attributes);
|
352
349
|
return RTEST(rb_ary_includes(boolean_attributes, key));
|
353
350
|
}
|
354
351
|
|
@@ -418,7 +415,7 @@ hamlit_build_for_boolean(VALUE escape_attrs, VALUE quote, VALUE format, VALUE bu
|
|
418
415
|
}
|
419
416
|
|
420
417
|
static VALUE
|
421
|
-
hamlit_build(VALUE escape_attrs, VALUE quote, VALUE format, VALUE object_ref, VALUE hashes)
|
418
|
+
hamlit_build(VALUE escape_attrs, VALUE quote, VALUE format, VALUE boolean_attributes, VALUE object_ref, VALUE hashes)
|
422
419
|
{
|
423
420
|
long i;
|
424
421
|
VALUE attrs, buf, key, keys, value;
|
@@ -439,7 +436,7 @@ hamlit_build(VALUE escape_attrs, VALUE quote, VALUE format, VALUE object_ref, VA
|
|
439
436
|
hamlit_build_for_data(escape_attrs, quote, buf, value);
|
440
437
|
} else if (str_eq(key, "aria", 4)) {
|
441
438
|
hamlit_build_for_aria(escape_attrs, quote, buf, value);
|
442
|
-
} else if (is_boolean_attribute(key)) {
|
439
|
+
} else if (is_boolean_attribute(key, boolean_attributes)) {
|
443
440
|
hamlit_build_for_boolean(escape_attrs, quote, format, buf, key, value);
|
444
441
|
} else {
|
445
442
|
hamlit_build_for_others(escape_attrs, quote, buf, key, value);
|
@@ -498,10 +495,10 @@ rb_hamlit_build(int argc, VALUE *argv, RB_UNUSED_VAR(VALUE self))
|
|
498
495
|
{
|
499
496
|
VALUE array;
|
500
497
|
|
501
|
-
rb_check_arity(argc,
|
502
|
-
rb_scan_args(argc -
|
498
|
+
rb_check_arity(argc, 5, UNLIMITED_ARGUMENTS);
|
499
|
+
rb_scan_args(argc - 5, argv + 5, "*", &array);
|
503
500
|
|
504
|
-
return hamlit_build(argv[0], argv[1], argv[2], argv[3], array);
|
501
|
+
return hamlit_build(argv[0], argv[1], argv[2], argv[3], argv[4], array);
|
505
502
|
}
|
506
503
|
|
507
504
|
void
|
@@ -527,9 +524,7 @@ Init_hamlit(void)
|
|
527
524
|
id_prepend = rb_intern("prepend");
|
528
525
|
id_tr = rb_intern("tr");
|
529
526
|
id_uniq_bang = rb_intern("uniq!");
|
530
|
-
|
531
|
-
id_boolean_attributes = rb_intern("BOOLEAN_ATTRIBUTES");
|
532
|
-
id_xhtml = rb_intern("xhtml");
|
527
|
+
id_xhtml = rb_intern("xhtml");
|
533
528
|
|
534
529
|
// Consider using rb_interned_str() once we stop supporting Ruby 2.7.
|
535
530
|
rb_gc_register_mark_object(str_aria = rb_obj_freeze(rb_str_new_cstr("aria")));
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Hamlit
|
3
|
+
class Ambles < Temple::Filter
|
4
|
+
define_options :preamble, :postamble
|
5
|
+
|
6
|
+
def initialize(*)
|
7
|
+
super
|
8
|
+
@preamble = options[:preamble]
|
9
|
+
@postamble = options[:postamble]
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(ast)
|
13
|
+
ret = [:multi]
|
14
|
+
ret << [:static, @preamble] if @preamble
|
15
|
+
ret << ast
|
16
|
+
ret << [:static, @postamble] if @postamble
|
17
|
+
ret
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -13,7 +13,7 @@ module Hamlit::AttributeBuilder
|
|
13
13
|
# TruffleRuby does not implement `rb_ary_sort_bang`, etc.
|
14
14
|
if /java/ === RUBY_PLATFORM || RUBY_ENGINE == 'truffleruby'
|
15
15
|
class << self
|
16
|
-
def build(escape_attrs, quote, format, object_ref, *hashes)
|
16
|
+
def build(escape_attrs, quote, format, boolean_attributes, object_ref, *hashes)
|
17
17
|
hashes << Hamlit::ObjectRef.parse(object_ref) if object_ref
|
18
18
|
buf = []
|
19
19
|
hash = merge_all_attrs(hashes)
|
@@ -27,7 +27,7 @@ module Hamlit::AttributeBuilder
|
|
27
27
|
buf << " class=#{quote}#{build_class(escape_attrs, *hash[key])}#{quote}"
|
28
28
|
when 'data'.freeze
|
29
29
|
buf << build_data(escape_attrs, quote, *hash[key])
|
30
|
-
when *
|
30
|
+
when *boolean_attributes, /\Adata-/
|
31
31
|
build_boolean!(escape_attrs, quote, format, buf, key, hash[key])
|
32
32
|
else
|
33
33
|
buf << " #{key}=#{quote}#{escape_html(escape_attrs, hash[key].to_s)}#{quote}"
|
@@ -31,7 +31,10 @@ module Hamlit
|
|
31
31
|
attrs = []
|
32
32
|
attrs.unshift(node.value[:attributes].inspect) if node.value[:attributes] != {}
|
33
33
|
|
34
|
-
args = [
|
34
|
+
args = [
|
35
|
+
@escape_attrs.inspect, "#{@quote.inspect}.freeze", @format.inspect,
|
36
|
+
'::Hamlit::AttributeBuilder::BOOLEAN_ATTRIBUTES', node.value[:object_ref],
|
37
|
+
] + attrs
|
35
38
|
[:html, :attrs, [:dynamic, "::Hamlit::AttributeBuilder.build(#{args.join(', ')}, #{node.value[:dynamic_attributes].to_literal})"]]
|
36
39
|
end
|
37
40
|
|
data/lib/hamlit/engine.rb
CHANGED
@@ -6,6 +6,7 @@ require 'hamlit/html'
|
|
6
6
|
require 'hamlit/escapable'
|
7
7
|
require 'hamlit/force_escapable'
|
8
8
|
require 'hamlit/dynamic_merger'
|
9
|
+
require 'hamlit/ambles'
|
9
10
|
|
10
11
|
module Hamlit
|
11
12
|
class Engine < Temple::Engine
|
@@ -30,6 +31,7 @@ module Hamlit
|
|
30
31
|
use Escapable
|
31
32
|
use ForceEscapable
|
32
33
|
filter :ControlFlow
|
34
|
+
use Ambles
|
33
35
|
filter :MultiFlattener
|
34
36
|
filter :StaticMerger
|
35
37
|
use DynamicMerger
|
@@ -33,6 +33,11 @@ module Hamlit
|
|
33
33
|
options = options.merge(format: :xhtml)
|
34
34
|
end
|
35
35
|
|
36
|
+
if ActionView::Base.try(:annotate_rendered_view_with_filenames) && template.format == :html
|
37
|
+
options[:preamble] = "<!-- BEGIN #{template.short_identifier} -->\n"
|
38
|
+
options[:postamble] = "<!-- END #{template.short_identifier} -->\n"
|
39
|
+
end
|
40
|
+
|
36
41
|
Engine.new(options).call(source)
|
37
42
|
end
|
38
43
|
|
data/lib/hamlit/railtie.rb
CHANGED
@@ -3,7 +3,12 @@ require 'rails'
|
|
3
3
|
|
4
4
|
module Hamlit
|
5
5
|
class Railtie < ::Rails::Railtie
|
6
|
-
initializer :hamlit do |app|
|
6
|
+
initializer :hamlit, before: :load_config_initializers do |app|
|
7
|
+
# Load haml/plugin first to override if available
|
8
|
+
begin
|
9
|
+
require 'haml/plugin'
|
10
|
+
rescue LoadError
|
11
|
+
end
|
7
12
|
require 'hamlit/rails_template'
|
8
13
|
end
|
9
14
|
end
|
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.
|
4
|
+
version: 2.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takashi Kokubun
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: temple
|
@@ -257,6 +257,7 @@ extensions:
|
|
257
257
|
- ext/hamlit/extconf.rb
|
258
258
|
extra_rdoc_files: []
|
259
259
|
files:
|
260
|
+
- ".github/FUNDING.yml"
|
260
261
|
- ".github/workflows/test.yml"
|
261
262
|
- ".gitignore"
|
262
263
|
- CHANGELOG.md
|
@@ -313,6 +314,7 @@ files:
|
|
313
314
|
- ext/hamlit/hescape.h
|
314
315
|
- hamlit.gemspec
|
315
316
|
- lib/hamlit.rb
|
317
|
+
- lib/hamlit/ambles.rb
|
316
318
|
- lib/hamlit/attribute_builder.rb
|
317
319
|
- lib/hamlit/attribute_compiler.rb
|
318
320
|
- lib/hamlit/attribute_parser.rb
|
@@ -376,7 +378,7 @@ homepage: https://github.com/k0kubun/hamlit
|
|
376
378
|
licenses:
|
377
379
|
- MIT
|
378
380
|
metadata: {}
|
379
|
-
post_install_message:
|
381
|
+
post_install_message:
|
380
382
|
rdoc_options: []
|
381
383
|
require_paths:
|
382
384
|
- lib
|
@@ -391,8 +393,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
391
393
|
- !ruby/object:Gem::Version
|
392
394
|
version: '0'
|
393
395
|
requirements: []
|
394
|
-
rubygems_version: 3.
|
395
|
-
signing_key:
|
396
|
+
rubygems_version: 3.2.3
|
397
|
+
signing_key:
|
396
398
|
specification_version: 4
|
397
399
|
summary: High Performance Haml Implementation
|
398
400
|
test_files: []
|