haml 5.2.2 → 6.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +3 -0
  3. data/.github/workflows/test.yml +13 -14
  4. data/.gitignore +16 -16
  5. data/.yardopts +0 -3
  6. data/CHANGELOG.md +116 -3
  7. data/Gemfile +18 -11
  8. data/MIT-LICENSE +1 -1
  9. data/README.md +17 -23
  10. data/REFERENCE.md +69 -145
  11. data/Rakefile +48 -81
  12. data/bin/bench +66 -0
  13. data/bin/console +11 -0
  14. data/bin/ruby +3 -0
  15. data/bin/setup +7 -0
  16. data/bin/stackprof +27 -0
  17. data/bin/test +24 -0
  18. data/exe/haml +6 -0
  19. data/ext/haml/extconf.rb +10 -0
  20. data/ext/haml/haml.c +537 -0
  21. data/ext/haml/hescape.c +108 -0
  22. data/ext/haml/hescape.h +20 -0
  23. data/haml.gemspec +39 -37
  24. data/lib/haml/ambles.rb +20 -0
  25. data/lib/haml/attribute_builder.rb +134 -179
  26. data/lib/haml/attribute_compiler.rb +85 -194
  27. data/lib/haml/attribute_parser.rb +92 -126
  28. data/lib/haml/cli.rb +154 -0
  29. data/lib/haml/compiler/children_compiler.rb +155 -0
  30. data/lib/haml/compiler/comment_compiler.rb +51 -0
  31. data/lib/haml/compiler/doctype_compiler.rb +46 -0
  32. data/lib/haml/compiler/script_compiler.rb +114 -0
  33. data/lib/haml/compiler/silent_script_compiler.rb +24 -0
  34. data/lib/haml/compiler/tag_compiler.rb +76 -0
  35. data/lib/haml/compiler.rb +63 -296
  36. data/lib/haml/dynamic_merger.rb +67 -0
  37. data/lib/haml/engine.rb +48 -227
  38. data/lib/haml/error.rb +5 -4
  39. data/lib/haml/escape.rb +13 -0
  40. data/lib/haml/escape_any.rb +21 -0
  41. data/lib/haml/filters/base.rb +12 -0
  42. data/lib/haml/filters/cdata.rb +20 -0
  43. data/lib/haml/filters/coffee.rb +17 -0
  44. data/lib/haml/filters/css.rb +33 -0
  45. data/lib/haml/filters/erb.rb +10 -0
  46. data/lib/haml/filters/escaped.rb +22 -0
  47. data/lib/haml/filters/javascript.rb +33 -0
  48. data/lib/haml/filters/less.rb +20 -0
  49. data/lib/haml/filters/markdown.rb +11 -0
  50. data/lib/haml/filters/plain.rb +29 -0
  51. data/lib/haml/filters/preserve.rb +22 -0
  52. data/lib/haml/filters/ruby.rb +10 -0
  53. data/lib/haml/filters/sass.rb +15 -0
  54. data/lib/haml/filters/scss.rb +15 -0
  55. data/lib/haml/filters/text_base.rb +25 -0
  56. data/lib/haml/filters/tilt_base.rb +59 -0
  57. data/lib/haml/filters.rb +54 -378
  58. data/lib/haml/force_escape.rb +29 -0
  59. data/lib/haml/helpers.rb +3 -697
  60. data/lib/haml/html.rb +22 -0
  61. data/lib/haml/identity.rb +13 -0
  62. data/lib/haml/object_ref.rb +35 -0
  63. data/lib/haml/parser.rb +157 -22
  64. data/lib/haml/rails_helpers.rb +53 -0
  65. data/lib/haml/rails_template.rb +57 -0
  66. data/lib/haml/railtie.rb +3 -46
  67. data/lib/haml/ruby_expression.rb +32 -0
  68. data/lib/haml/string_splitter.rb +140 -0
  69. data/lib/haml/template.rb +15 -34
  70. data/lib/haml/temple_line_counter.rb +2 -1
  71. data/lib/haml/util.rb +18 -15
  72. data/lib/haml/version.rb +1 -2
  73. data/lib/haml/whitespace.rb +8 -0
  74. data/lib/haml.rb +8 -20
  75. metadata +211 -55
  76. data/.gitmodules +0 -3
  77. data/TODO +0 -24
  78. data/benchmark.rb +0 -70
  79. data/bin/haml +0 -9
  80. data/lib/haml/.gitattributes +0 -1
  81. data/lib/haml/buffer.rb +0 -182
  82. data/lib/haml/escapable.rb +0 -77
  83. data/lib/haml/exec.rb +0 -347
  84. data/lib/haml/generator.rb +0 -42
  85. data/lib/haml/helpers/action_view_extensions.rb +0 -60
  86. data/lib/haml/helpers/action_view_mods.rb +0 -132
  87. data/lib/haml/helpers/action_view_xss_mods.rb +0 -60
  88. data/lib/haml/helpers/safe_erubi_template.rb +0 -20
  89. data/lib/haml/helpers/safe_erubis_template.rb +0 -33
  90. data/lib/haml/helpers/xss_mods.rb +0 -114
  91. data/lib/haml/options.rb +0 -273
  92. data/lib/haml/plugin.rb +0 -54
  93. data/lib/haml/sass_rails_filter.rb +0 -47
  94. data/lib/haml/template/options.rb +0 -27
  95. data/lib/haml/temple_engine.rb +0 -124
  96. data/yard/default/.gitignore +0 -1
  97. data/yard/default/fulldoc/html/css/common.sass +0 -15
  98. data/yard/default/layout/html/footer.erb +0 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ec6cbb2e4023f397f1d7b6d84f06d78ab492a61e88c3f16496f39d0baeb47a83
4
- data.tar.gz: 004c2dd34697cb61a8c12854bf4b99abb3cab5195f28922b813ee299225e7663
3
+ metadata.gz: 1c6e33698052b2d1823959741be8219446b8b3257f5124449daa8cd8deb70e4a
4
+ data.tar.gz: d2a168766babc32a3f83b065e6d158e5b937995cdd5a46552fb95d4035ad5924
5
5
  SHA512:
6
- metadata.gz: a7430b4e42cf809f847448a9e04623b4b58878e44facedef5e43714820e8068f0bb853772564d5545936cdad8346f0c33abfc11642a3737d91c9a1f6242b3e41
7
- data.tar.gz: 8a91df0cb185014512ee473a21755ba41edb06e835b29740e8e46c76287a81405b2706d8a10ea148893a9429de306c67584ac1c286637c0812a5562cf149431b
6
+ metadata.gz: c6d71bcdb86f5281b34c9f56684263db88e947b17c8d79eb764b6ecb8f17945ad7fc374b2ad8032066b0c7ae52e3c0045de3658b76fc073e5ee8ab73e3c7eae3
7
+ data.tar.gz: 408d9dd0b14378515d175778a9d9b472b70819c2371189aa145d2e787590213f453bba60e6dec2aee5aadf9e7bc0fd6c4b077f96676c9b6e899896ce60eb07cc
@@ -0,0 +1,3 @@
1
+ github:
2
+ - haml
3
+ - k0kubun
@@ -8,29 +8,28 @@ on:
8
8
  - opened
9
9
  - synchronize
10
10
  - reopened
11
+ schedule:
12
+ - cron: "00 15 * * *"
11
13
  jobs:
12
14
  test:
13
- name: 'Ruby: ${{ matrix.ruby }}, Rails: ${{ matrix.rails }}'
14
15
  runs-on: ubuntu-latest
15
16
  strategy:
16
17
  fail-fast: false
17
18
  matrix:
18
- ruby: [2.6, 2.7, 3.0, jruby-9.2]
19
- rails: [5.2.x, 6.0.x, 6.1.x, rails-edge]
19
+ ruby:
20
+ - '2.5'
21
+ - '2.6'
22
+ - '2.7'
23
+ - '3.0'
24
+ - '3.1'
25
+ - jruby
26
+ - truffleruby-head
20
27
  steps:
21
28
  - uses: actions/checkout@v2
29
+ - run: sudo apt-get update && sudo apt-get install -y nodejs libxslt-dev # nodejs for execjs, libxslt for TruffleRuby nokogiri
22
30
  - name: Set up Ruby
23
31
  uses: ruby/setup-ruby@v1
24
32
  with:
25
33
  ruby-version: ${{ matrix.ruby }}
26
- - uses: actions/cache@v2
27
- with:
28
- path: vendor/bundle
29
- key: ${{ runner.os }}-${{ matrix.ruby }}-gems-${{ hashFiles('**/Gemfile.lock') }}
30
- restore-keys: ${{ runner.os }}-gems-
31
- - name: bundle install --gemfile=test/gemfiles/Gemfile.rails-${{matrix.rails}}.x
32
- run: bundle config path vendor/bundle && bundle install -j$(nproc) --retry 3
33
- - name: rake test
34
- run: bundle exec rake test submodules
35
- env:
36
- RUBYOPT: "--enable-frozen-string-literal"
34
+ bundler-cache: true
35
+ - run: bundle exec rake test
data/.gitignore CHANGED
@@ -1,19 +1,19 @@
1
- /.idea
1
+ /.bundle/
2
2
  /.yardoc
3
- /coverage
4
- /doc
5
- /log
6
- /pkg
7
- /test/rails
8
- /test/gemfiles/*.lock
9
- /.haml
10
- /site
11
- *.rbc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /.idea
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+ /haml/
12
12
  .sass-cache
13
- .rbenv-version
14
- .rbx
15
13
  .ruby-version
16
- .rvmrc
17
- Gemfile.lock
18
- tmp
19
- .bundle/
14
+ *.bundle
15
+ *.so
16
+ *.su
17
+ *.a
18
+ *.o
19
+ *.swp
data/.yardopts CHANGED
@@ -7,10 +7,7 @@
7
7
  --title "Haml Documentation"
8
8
  --query 'object.type != :classvariable'
9
9
  --query 'object.type != :constant || @api && @api.text == "public"'
10
- --exclude lib/haml/plugin.rb
11
10
  --exclude lib/haml/railtie.rb
12
- --exclude lib/haml/helpers/action_view_mods.rb
13
- --exclude lib/haml/helpers/xss_mods.rb
14
11
  --hide-void-return
15
12
  --protected
16
13
  --no-private
data/CHANGELOG.md CHANGED
@@ -1,12 +1,125 @@
1
1
  # Haml Changelog
2
2
 
3
+ ## 6.1.1
4
+
5
+ * Fix an empty output of Ruby 3.1's Hash shorthand syntax [#1083](https://github.com/haml/haml/issues/1083)
6
+
7
+ ## 6.1.0
8
+
9
+ * Optimize away a `to_s` call on `=` scripts
10
+ * Fix escaping for objects that return an `html_safe` string on `to_s` [#1117](https://github.com/haml/haml/issues/1117)
11
+
12
+ ## 6.0.12
13
+
14
+ * Fix a whitespace removal with `>` and an `if`-`else` statement [#1114](https://github.com/haml/haml/issues/1114)
15
+
16
+ ## 6.0.11
17
+
18
+ * Fix a whitespace removal with `>` and an `if` statement [#1114](https://github.com/haml/haml/issues/1114)
19
+
20
+ ## 6.0.10
21
+
22
+ * Evaluate :erb filter in the template context like Haml 5
23
+
24
+ ## 6.0.9
25
+
26
+ * Support sass-embedded [#1112](https://github.com/haml/haml/issues/1112)
27
+
28
+ ## 6.0.8
29
+
30
+ * Support interpolation in HTML comments, which has not been working since 6.0.0
31
+ [#1107](https://github.com/haml/haml/issues/1107)
32
+
33
+ ## 6.0.7
34
+
35
+ * `Haml::Engine` and `Haml::Template` use StringBuffer instead of ArrayBuffer
36
+ * It seems more performant in many cases with recent Ruby versions.
37
+ * `Haml::RailsTemplate` is not affected.
38
+
39
+ ## 6.0.6
40
+
41
+ * Prevent CRuby from accidentally using the Ruby implementation fallback
42
+ * Reversing what v6.0.3 and v6.0.4 did, but still supporting Wasm.
43
+
44
+ ## 6.0.5
45
+
46
+ * Resurrect `#haml_object_ref` support in an object reference [#1097](https://github.com/haml/haml/issues/1097)
47
+ * This was removed in 6.0.0, and added back in this version.
48
+ * Stop warning `remove_whitespace: true` option.
49
+
50
+ ## 6.0.4
51
+
52
+ Released on October 2, 2022
53
+ ([diff](https://github.com/haml/haml/compare/v6.0.3...v6.0.4)).
54
+
55
+ * Fix a parse failure of `%` in attributes [#1096](https://github.com/haml/haml/issues/1096)
56
+ * Add another fallback from C to Ruby for Wasm.
57
+
58
+ ## 6.0.3
59
+
60
+ Released on September 28, 2022
61
+ ([diff](https://github.com/haml/haml/compare/v6.0.2...v6.0.3)).
62
+
63
+ * For Wasm, fallback to Ruby when C extension is not available.
64
+
65
+ ## 6.0.2
66
+
67
+ Released on September 28, 2022
68
+ ([diff](https://github.com/haml/haml/compare/v6.0.1...v6.0.2)).
69
+
70
+ * Unescape HTML-safe arguments for `surround`, `succeed`, and `precede` on Rails
71
+ [#1088](https://github.com/haml/haml/issues/1088)
72
+
73
+ ## 6.0.1
74
+
75
+ Released on September 23, 2022
76
+ ([diff](https://github.com/haml/haml/compare/v6.0.0...v6.0.1)).
77
+
78
+ * Unescape HTML-safe interpolation on Rails [#1084](https://github.com/haml/haml/issues/1084)
79
+ * Resurrect Haml 5's `AttributeParser.available?` for syntax\_tree-haml [#1085](https://github.com/haml/haml/issues/1085)
80
+
81
+ ## 6.0.0
82
+
83
+ Released on September 21, 2022
84
+ ([diff](https://github.com/haml/haml/compare/v5.2.2...v6.0.0)).
85
+
86
+ * Replace the implementation with Hamlit
87
+ * Haml 6 is about 1.7x faster than Haml 5 in [this benchmark](benchmark/slim/run-benchmarks.rb).
88
+ * The parser is kept as is, but everything else is replaced.
89
+ * The `haml` CLI interface was also replaced.
90
+ * The interface of `Haml::Engine` is changed. `Haml::Template` is most likely what you need now.
91
+ * before: `Haml::Engine.new("%p Haml code!").render`
92
+ * after: `Haml::Template.new { "%p Haml code!" }.render`
93
+ * Most Haml helpers are removed.
94
+ * Rails:
95
+ * Kept: `find_and_reserve`, `preserve`, `surround`, `precede`, `succeed`, `capture_haml`
96
+ * Removed: `block_is_haml?`, `flatten`, `haml_concat`, `haml_indent`, `haml_tag`, `haml_tag_if`, `html_attrs`,
97
+ `html_escape`, `init_haml_helpers`, `is_haml?`, `list_of`, `non_haml`, `tab_down`, `tab_up`, `with_tabs`
98
+ * Tilt:
99
+ * Kept: `preserve`
100
+ * Removed: `block_is_haml?`, `capture_haml`, `escape_once`, `find_and_preserve`, `flatten`, `haml_concat`,
101
+ `haml_indent`, `haml_tag`, `haml_tag_if`, `html_attrs`, `html_escape`, `init_haml_helpers`, `is_haml?`,
102
+ `list_of`, `non_haml`, `precede`, `succeed`, `surround`, `tab_down`, `tab_up`, `with_tabs`
103
+ * Only the following attributes and `aria`/`data` attributes are considered boolean attributes:
104
+ * `allowfullscreen`, `async`, `autobuffer`, `autofocus`, `autoplay`, `checked`, `controls`, `default`,
105
+ `defer`, `disabled`, `download`, `formnovalidate`, `hidden`, `inert`, `ismap`, `itemscope`, `loop`,
106
+ `multiple`, `muted`, `novalidate`, `open`, `pubdate`, `readonly`, `required`, `reversed`, `scoped`,
107
+ `seamless`, `selected`, `sortable`, `truespeed`, `typemustmatch`
108
+ * Only `data` and `aria` attributes support using a nested Hash to render hyphenated attributes, e.g.
109
+ `data: { foo: 'bar' }` becomes `data-foo="bar"`, but this no longer works for non-`data`/`aria` attributes.
110
+ * Some legacy Rails integration is removed.
111
+ * The default value of `escape_html` option became true.
112
+ * `-` script lines no longer support capturing. Only `=` lines are supported to yield a nested block.
113
+ * Overriding `data` attributes with another falsy `data-*` attribute that has the same name
114
+ is no longer supported. [#1105](https://github.com/haml/haml/issues/1105)
115
+ * :erb filter is not executed in the template context (fixed in 6.0.10)
116
+
3
117
  ## 5.2.2
118
+
4
119
  Released on July 27, 2021
5
120
  ([diff](https://github.com/haml/haml/compare/v5.2.1...v5.2.2)).
6
121
 
7
- * Support for adding Annotations to Haml output (a Rails feature 6.1+)
8
- * Expanded test matrix to include Ruby 3.0 and Rails 6.1
9
- * Only testing Ruby 2.7+ and Rails 5.2+
122
+ * Support `config.action_view.annotate_rendered_view_with_filenames = true` of Rails 6.1
10
123
 
11
124
  ## 5.2.1
12
125
 
data/Gemfile CHANGED
@@ -1,16 +1,23 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
+
3
+ git_source(:github) do |repo_name|
4
+ repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
5
+ "https://github.com/#{repo_name}.git"
6
+ end
7
+
8
+ # Specify your gem's dependencies in haml.gemspec
2
9
  gemspec
3
10
 
4
- gem "m"
5
- gem "pry"
6
- gem "simplecov"
11
+ gem 'benchmark-ips', '2.3.0'
12
+ gem 'maxitest'
13
+ gem 'pry'
7
14
 
8
- group :docs do
9
- gem "yard"
10
- gem "kramdown"
11
- gem "sass"
12
- end
15
+ if /java/ === RUBY_PLATFORM # JRuby
16
+ gem 'pandoc-ruby'
17
+ else
18
+ gem 'redcarpet'
13
19
 
14
- platform :mri do
15
- gem "ruby-prof"
20
+ if RUBY_PLATFORM !~ /mswin|mingw/ && RUBY_ENGINE != 'truffleruby'
21
+ gem 'stackprof'
22
+ end
16
23
  end
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2006-2019 Hampton Catlin and Natalie Weizenbaum
1
+ Copyright (c) 2006-2021 Hampton Catlin, Natalie Weizenbaum and Takashi Kokubun
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Haml
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/haml.svg)](http://rubygems.org/gems/haml)
4
- [![Build Status](https://travis-ci.org/haml/haml.svg?branch=main)](http://travis-ci.org/haml/haml)
4
+ [![test](https://github.com/haml/haml/actions/workflows/test.yml/badge.svg)](https://github.com/haml/haml/actions/workflows/test.yml)
5
5
  [![Code Climate](https://codeclimate.com/github/haml/haml/badges/gpa.svg)](https://codeclimate.com/github/haml/haml)
6
6
  [![Inline docs](http://inch-ci.org/github/haml/haml.png)](http://inch-ci.org/github/haml/haml)
7
7
 
@@ -10,13 +10,6 @@ more pleasant to write HTML documents, by eliminating redundancy, reflecting the
10
10
  underlying structure that the document represents, and providing an elegant syntax
11
11
  that's both powerful and easy to understand.
12
12
 
13
- ### Supported Versions
14
-
15
- * Ruby 2.6+
16
- * Rails 5.1+
17
-
18
- Other versions may likely work, but we don't test against them.
19
-
20
13
  ## Basic Usage
21
14
 
22
15
  Haml can be used from the command line or as part of a Ruby web framework. The
@@ -29,7 +22,7 @@ gem install haml
29
22
  After you write some Haml, you can run
30
23
 
31
24
  ~~~sh
32
- haml document.haml
25
+ haml render document.haml
33
26
  ~~~
34
27
 
35
28
  to compile it to HTML. For more information on these commands, check out
@@ -48,8 +41,8 @@ To use Haml with Rails, simply add Haml to your Gemfile and run `bundle`.
48
41
  gem 'haml'
49
42
  ~~~
50
43
 
51
- If you'd like to replace Rails's Erb-based generators with Haml, add
52
- [haml-rails](https://github.com/indirect/haml-rails) to your Gemfile as well.
44
+ If you'd like to replace Rails's ERB-based generators with Haml, add
45
+ [haml-rails](https://github.com/haml/haml-rails) to your Gemfile as well.
53
46
 
54
47
  ## Formatting
55
48
 
@@ -169,34 +162,35 @@ on a specific area:
169
162
  ruby -Itest test/helper_test.rb -n test_buffer_access
170
163
  ~~~
171
164
 
172
- Haml currently supports Ruby 2.7.0 and higher, so please make sure your changes run on 2.7+.
165
+ Haml currently supports Ruby 2.0.0 and higher, so please make sure your changes run on 2.0+.
173
166
 
174
167
  ## Team
175
168
 
176
169
  ### Current Maintainers
177
170
 
178
- * [Hampton Catlin](https://github.com/hcatlin)
179
- * [Takashi Kokubun](https://github.com/k0kubun)
180
171
  * [Akira Matsuda](https://github.com/amatsuda)
172
+ * [Matt Wildig](https://github.com/mattwildig)
173
+ * [Tee Parham](https://github.com/teeparham)
174
+ * [Takashi Kokubun](https://github.com/k0kubun)
181
175
 
182
176
  ### Alumni
183
177
 
184
178
  Haml was created by [Hampton Catlin](http://hamptoncatlin.com), the author of
185
- the original implementation.
179
+ the original implementation. Hampton is no longer involved in day-to-day coding,
180
+ but still consults on language issues.
186
181
 
187
- [Natalie Weizenbaum](https://github.com/nex3) was for many years the primary developer
182
+ [Natalie Weizenbaum](http://nex-3.com) was for many years the primary developer
188
183
  and architect of the "modern" Ruby implementation of Haml.
189
184
 
190
- This project's been around for many years, and we have many amazing people who kept the project
191
- alive! as former maintainers like:
192
-
193
- [Norman Clarke](http://github.com/norman)
194
- [Matt Wildig](https://github.com/mattwildig)
195
- [Tee Parham](https://github.com/teeparham)
185
+ [Norman Clarke](http://github.com/norman) was the primary maintainer of Haml from 2012 to 2016.
196
186
 
197
187
  ## License
198
188
 
199
- Copyright (c) 2006-2021 Hampton Catlin, Natalie Weizenbaum and the Haml team
189
+ Some of Natalie's work on Haml was supported by Unspace Interactive.
190
+
191
+ Beyond that, the implementation is licensed under the MIT License.
192
+
193
+ Copyright (c) 2006-2019 Hampton Catlin, Natalie Weizenbaum and the Haml team
200
194
 
201
195
  Permission is hereby granted, free of charge, to any person obtaining a copy of
202
196
  this software and associated documentation files (the "Software"), to deal in