haml 5.1.2 → 6.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +3 -0
  3. data/.github/workflows/test.yml +35 -0
  4. data/.gitignore +16 -15
  5. data/.yardopts +0 -3
  6. data/CHANGELOG.md +137 -0
  7. data/Gemfile +18 -14
  8. data/MIT-LICENSE +1 -1
  9. data/README.md +5 -6
  10. data/REFERENCE.md +103 -150
  11. data/Rakefile +48 -88
  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 -36
  24. data/lib/haml/ambles.rb +20 -0
  25. data/lib/haml/attribute_builder.rb +139 -129
  26. data/lib/haml/attribute_compiler.rb +86 -182
  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 -691
  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 +189 -26
  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 -41
  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 +19 -16
  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 +222 -52
  76. data/.gitmodules +0 -3
  77. data/.travis.yml +0 -97
  78. data/TODO +0 -24
  79. data/benchmark.rb +0 -70
  80. data/bin/haml +0 -9
  81. data/lib/haml/.gitattributes +0 -1
  82. data/lib/haml/buffer.rb +0 -238
  83. data/lib/haml/escapable.rb +0 -50
  84. data/lib/haml/exec.rb +0 -347
  85. data/lib/haml/generator.rb +0 -42
  86. data/lib/haml/helpers/action_view_extensions.rb +0 -60
  87. data/lib/haml/helpers/action_view_mods.rb +0 -132
  88. data/lib/haml/helpers/action_view_xss_mods.rb +0 -60
  89. data/lib/haml/helpers/safe_erubi_template.rb +0 -20
  90. data/lib/haml/helpers/safe_erubis_template.rb +0 -33
  91. data/lib/haml/helpers/xss_mods.rb +0 -111
  92. data/lib/haml/options.rb +0 -273
  93. data/lib/haml/plugin.rb +0 -37
  94. data/lib/haml/sass_rails_filter.rb +0 -47
  95. data/lib/haml/template/options.rb +0 -27
  96. data/lib/haml/temple_engine.rb +0 -123
  97. data/yard/default/.gitignore +0 -1
  98. data/yard/default/fulldoc/html/css/common.sass +0 -15
  99. data/yard/default/layout/html/footer.erb +0 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2ab71634acdfecb8525662d862961b21f26d77f32adf34457443b96aa5118b8d
4
- data.tar.gz: 3eae0d107f253137df0583ead35dfee0d7840d3de616db50e0dbbd5734acbe27
3
+ metadata.gz: 1c6e33698052b2d1823959741be8219446b8b3257f5124449daa8cd8deb70e4a
4
+ data.tar.gz: d2a168766babc32a3f83b065e6d158e5b937995cdd5a46552fb95d4035ad5924
5
5
  SHA512:
6
- metadata.gz: fb8005b129e6874259a4ff900579a13cbc42c3f64b13640856a219c9f69fbd2cfc77d8126231148c2ebc6b58883e8687a4f447603fd6cdfc41195bf08e1127c3
7
- data.tar.gz: 813db45e219554933892a41e023419e9a1a0e10602ebdf525f7efc1f14fe6f2afa4ff96ac691a0d8552989016453e7ce553864fc778447e1f55725de43b53406
6
+ metadata.gz: c6d71bcdb86f5281b34c9f56684263db88e947b17c8d79eb764b6ecb8f17945ad7fc374b2ad8032066b0c7ae52e3c0045de3658b76fc073e5ee8ab73e3c7eae3
7
+ data.tar.gz: 408d9dd0b14378515d175778a9d9b472b70819c2371189aa145d2e787590213f453bba60e6dec2aee5aadf9e7bc0fd6c4b077f96676c9b6e899896ce60eb07cc
@@ -0,0 +1,3 @@
1
+ github:
2
+ - haml
3
+ - k0kubun
@@ -0,0 +1,35 @@
1
+ name: test
2
+ on:
3
+ push:
4
+ branches:
5
+ - main
6
+ pull_request:
7
+ types:
8
+ - opened
9
+ - synchronize
10
+ - reopened
11
+ schedule:
12
+ - cron: "00 15 * * *"
13
+ jobs:
14
+ test:
15
+ runs-on: ubuntu-latest
16
+ strategy:
17
+ fail-fast: false
18
+ matrix:
19
+ ruby:
20
+ - '2.5'
21
+ - '2.6'
22
+ - '2.7'
23
+ - '3.0'
24
+ - '3.1'
25
+ - jruby
26
+ - truffleruby-head
27
+ steps:
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
30
+ - name: Set up Ruby
31
+ uses: ruby/setup-ruby@v1
32
+ with:
33
+ ruby-version: ${{ matrix.ruby }}
34
+ bundler-cache: true
35
+ - run: bundle exec rake test
data/.gitignore CHANGED
@@ -1,18 +1,19 @@
1
+ /.bundle/
1
2
  /.yardoc
2
- /coverage
3
- /doc
4
- /log
5
- /pkg
6
- /test/rails
7
- /test/gemfiles/*.lock
8
- /.haml
9
- /site
10
- *.rbc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /.idea
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+ /haml/
11
12
  .sass-cache
12
- .rbenv-version
13
- .rbx
14
13
  .ruby-version
15
- .rvmrc
16
- Gemfile.lock
17
- tmp
18
- .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,5 +1,142 @@
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
+
117
+ ## 5.2.2
118
+
119
+ Released on July 27, 2021
120
+ ([diff](https://github.com/haml/haml/compare/v5.2.1...v5.2.2)).
121
+
122
+ * Support `config.action_view.annotate_rendered_view_with_filenames = true` of Rails 6.1
123
+
124
+ ## 5.2.1
125
+
126
+ Released on November 30, 2020
127
+ ([diff](https://github.com/haml/haml/compare/v5.2.0...v5.2.1)).
128
+
129
+ * Add in improved "multiline" support for attributes [#1043](https://github.com/haml/haml/issues/1043)
130
+
131
+ ## 5.2
132
+
133
+ Released on September 28, 2020
134
+ ([diff](https://github.com/haml/haml/compare/v5.1.2...v5.2.0)).
135
+
136
+ * Fix crash in the attribute optimizer when `#inspect` is overridden in TrueClass / FalseClass [#972](https://github.com/haml/haml/issues/972)
137
+ * Do not HTML-escape templates that are declared to be plaintext [#1014](https://github.com/haml/haml/issues/1014) (Thanks [@cesarizu](https://github.com/cesarizu))
138
+ * Class names are no longer ordered alphabetically, and now follow a new specification as laid out in REFERENCE [#306](https://github.com/haml/haml/issues/306)
139
+
3
140
  ## 5.1.2
4
141
 
5
142
  Released on August 6, 2019
data/Gemfile CHANGED
@@ -1,19 +1,23 @@
1
- source "https://rubygems.org"
2
- gemspec
3
-
4
- gem "m"
5
- gem "pry"
1
+ source 'https://rubygems.org'
6
2
 
7
- group :docs do
8
- gem "yard"
9
- gem "kramdown"
10
- gem "sass"
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"
11
6
  end
12
7
 
13
- platform :mri do
14
- gem "ruby-prof"
15
- end
8
+ # Specify your gem's dependencies in haml.gemspec
9
+ gemspec
10
+
11
+ gem 'benchmark-ips', '2.3.0'
12
+ gem 'maxitest'
13
+ gem 'pry'
14
+
15
+ if /java/ === RUBY_PLATFORM # JRuby
16
+ gem 'pandoc-ruby'
17
+ else
18
+ gem 'redcarpet'
16
19
 
17
- platform :mri_21 do
18
- gem "simplecov"
20
+ if RUBY_PLATFORM !~ /mswin|mingw/ && RUBY_ENGINE != 'truffleruby'
21
+ gem 'stackprof'
22
+ end
19
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,9 +1,8 @@
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=master)](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
- [![Coverage Status](http://img.shields.io/coveralls/haml/haml.svg)](https://coveralls.io/r/haml/haml)
7
6
  [![Inline docs](http://inch-ci.org/github/haml/haml.png)](http://inch-ci.org/github/haml/haml)
8
7
 
9
8
  Haml is a templating engine for HTML. It's designed to make it both easier and
@@ -23,7 +22,7 @@ gem install haml
23
22
  After you write some Haml, you can run
24
23
 
25
24
  ~~~sh
26
- haml document.haml
25
+ haml render document.haml
27
26
  ~~~
28
27
 
29
28
  to compile it to HTML. For more information on these commands, check out
@@ -32,7 +31,7 @@ to compile it to HTML. For more information on these commands, check out
32
31
  haml --help
33
32
  ~~~
34
33
 
35
- To use Haml programatically, check out the [YARD documentation](http://haml.info/docs/yardoc/).
34
+ To use Haml programmatically, check out the [YARD documentation](http://haml.info/docs/yardoc/).
36
35
 
37
36
  ## Using Haml with Rails
38
37
 
@@ -42,8 +41,8 @@ To use Haml with Rails, simply add Haml to your Gemfile and run `bundle`.
42
41
  gem 'haml'
43
42
  ~~~
44
43
 
45
- If you'd like to replace Rails's Erb-based generators with Haml, add
46
- [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.
47
46
 
48
47
  ## Formatting
49
48