haml 6.0.5 → 6.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e9efb6d42c07f38f08e6406c470be766f751439a63c0b151aca4040d5ea583d8
4
- data.tar.gz: 8bcc4b22a87eb105e380990aa1fcfee19c9cf1ae61467e9bb9c3130f81977279
3
+ metadata.gz: 9ff76f0fdc08205d557aad04a3701f7aad3df7badb119afe88c3a538fad318e8
4
+ data.tar.gz: a9bae0ed0aab397b6718df223ae9d093c94b349ecf1a0c0306d7faa446c53e3f
5
5
  SHA512:
6
- metadata.gz: 07ebd7d512eac2b19e8d8d2d2611064a4742ead90ad9e6570e7612dd45535797d4479aa169371105a37f9f9ba32e6066337ef4a772b7430c7d2ac3a519d34ebb
7
- data.tar.gz: 2fae2a68a205536580450fdd0c1ee1ab2c7f14268a01cc65b225f2115a1b3ee529865c2c184fc9b18e7a2141f6cb08d7a2254f14e0a7d5f61bde477387a114f9
6
+ metadata.gz: bdd2458541e841265ae99d5825a5d76fab8b977d8fd38ae110e19b73dbd1059616de97e6963d5feb42f15cc5b7648887646f4f6a17ec4fbe6aec883ef61865a6
7
+ data.tar.gz: c3dd71673d91323183695d6d734102422caabad995b76574a7a11ec59703cfc31302df250f6a679e974c7f4f6be50eff6b44c06a0ad45a2d47257a259de07af8
@@ -25,16 +25,10 @@ jobs:
25
25
  - truffleruby-head
26
26
  steps:
27
27
  - uses: actions/checkout@v2
28
+ - run: sudo apt-get update && sudo apt-get install -y nodejs libxslt-dev # nodejs for execjs, libxslt for TruffleRuby nokogiri
28
29
  - name: Set up Ruby
29
30
  uses: ruby/setup-ruby@v1
30
31
  with:
31
32
  ruby-version: ${{ matrix.ruby }}
32
- - uses: actions/cache@v2
33
- with:
34
- path: vendor/bundle
35
- key: ${{ runner.os }}-${{ matrix.ruby }}-gems-${{ hashFiles('**/Gemfile.lock') }}
36
- restore-keys: ${{ runner.os }}-gems-
37
- - run: sudo apt-get update && sudo apt-get install -y nodejs libxslt-dev # nodejs for execjs, libxslt for TruffleRuby nokogiri
38
- - name: bundle install
39
- run: bundle config path vendor/bundle && bundle install -j$(nproc) --retry 3
33
+ bundler-cache: true
40
34
  - run: bundle exec rake test
data/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Haml Changelog
2
2
 
3
+ ## 6.0.8
4
+
5
+ * Support interpolation in HTML comments, which has not been working since 6.0.0
6
+ [#1107](https://github.com/haml/haml/issues/1107)
7
+
8
+ ## 6.0.7
9
+
10
+ * `Haml::Engine` and `Haml::Template` use StringBuffer instead of ArrayBuffer
11
+ * It seems more performant in many cases with recent Ruby versions.
12
+ * `Haml::RailsTemplate` is not affected.
13
+
14
+ ## 6.0.6
15
+
16
+ * Prevent CRuby from accidentally using the Ruby implementation fallback
17
+ * Reversing what v6.0.3 and v6.0.4 did, but still supporting Wasm.
18
+
3
19
  ## 6.0.5
4
20
 
5
21
  * Resurrect `#haml_object_ref` support in an object reference [#1097](https://github.com/haml/haml/issues/1097)
@@ -57,9 +73,16 @@ Released on September 21, 2022
57
73
  * Removed: `block_is_haml?`, `capture_haml`, `escape_once`, `find_and_preserve`, `flatten`, `haml_concat`,
58
74
  `haml_indent`, `haml_tag`, `haml_tag_if`, `html_attrs`, `html_escape`, `init_haml_helpers`, `is_haml?`,
59
75
  `list_of`, `non_haml`, `precede`, `succeed`, `surround`, `tab_down`, `tab_up`, `with_tabs`
60
- * Only the attributes in [`Haml::AttributeBuilder::BOOLEAN_ATTRIBUTES`](lib/haml/attribute_builder.rb)
61
- are handled as boolean attributes.
76
+ * Only the following attributes and `aria`/`data` attributes are considered boolean attributes:
77
+ * `allowfullscreen`, `async`, `autobuffer`, `autofocus`, `autoplay`, `checked`, `controls`, `default`,
78
+ `defer`, `disabled`, `download`, `formnovalidate`, `hidden`, `inert`, `ismap`, `itemscope`, `loop`,
79
+ `multiple`, `muted`, `novalidate`, `open`, `pubdate`, `readonly`, `required`, `reversed`, `scoped`,
80
+ `seamless`, `selected`, `sortable`, `truespeed`, `typemustmatch`
62
81
  * Some legacy Rails integration is removed.
82
+ * The default value of `escape_html` option became true.
83
+ * `-` script lines no longer support capturing. Only `=` lines are supported to yield a nested block.
84
+ * Overriding `data` attributes with another falsy `data-*` attribute that has the same name
85
+ is no longer supported. [#1105](https://github.com/haml/haml/issues/1105)
63
86
 
64
87
  ## 5.2.2
65
88
 
data/REFERENCE.md CHANGED
@@ -1201,6 +1201,44 @@ default. This filter is implemented using Tilt.
1201
1201
  You can also define your own filters.
1202
1202
  `Haml::Filters::YourCustomFilter#compile` should return
1203
1203
  [a Temple expression](https://github.com/judofyr/temple/blob/master/EXPRESSIONS.md).
1204
+
1205
+ The simplest example of a filter might be something like:
1206
+
1207
+ ```ruby
1208
+ class HelloFilter < Haml::Filters::Base
1209
+ def compile(_node)
1210
+ [:static, "hello world"]
1211
+ end
1212
+ end
1213
+
1214
+ Haml::Filters.registered[:hello] ||= HelloFilter
1215
+ ```
1216
+
1217
+ A more complex complex example
1218
+
1219
+ ```ruby
1220
+ class BetterFilter < Haml::Filters::Base
1221
+ def compile(node)
1222
+ temple = [:multi]
1223
+ temple << [:static, "hello "]
1224
+ temple << compile_text(node.value[:text])
1225
+ temple << [:static, " world"]
1226
+ temple
1227
+ end
1228
+
1229
+ private
1230
+ def compile_text(text)
1231
+ if ::Haml::Util.contains_interpolation?(text)
1232
+ [:dynamic, ::Haml::Util.unescape_interpolation(text)]
1233
+ else
1234
+ [:static, text]
1235
+ end
1236
+ end
1237
+ end
1238
+
1239
+ Haml::Filters.registered[:better] ||= BetterFilter
1240
+ ```
1241
+
1204
1242
  See {Haml::Filters} for examples.
1205
1243
 
1206
1244
  ## Multiline: `|` {#multiline}
@@ -9,15 +9,8 @@ module Haml::AttributeBuilder
9
9
  itemscope allowfullscreen default inert sortable
10
10
  truespeed typemustmatch download].freeze
11
11
 
12
- begin
13
- # Haml::AttributeBuilder.build
14
- # Haml::AttributeBuilder.build_id
15
- # Haml::AttributeBuilder.build_class
16
- # Haml::AttributeBuilder.build_data
17
- # Haml::AttributeBuilder.build_aria
18
- require 'haml/haml'
19
- rescue LoadError
20
- # For JRuby and Wasm, fallback to Ruby implementation when C extension is not available.
12
+ # For JRuby, TruffleRuby, and Wasm, fallback to Ruby implementation.
13
+ if /java|wasm/ === RUBY_PLATFORM || RUBY_ENGINE == 'truffleruby'
21
14
  class << self
22
15
  def build(escape_attrs, quote, format, boolean_attributes, object_ref, *hashes)
23
16
  hashes << Haml::ObjectRef.parse(object_ref) if object_ref
@@ -170,5 +163,12 @@ module Haml::AttributeBuilder
170
163
  end
171
164
  end
172
165
  end
166
+ else
167
+ # Haml::AttributeBuilder.build
168
+ # Haml::AttributeBuilder.build_id
169
+ # Haml::AttributeBuilder.build_class
170
+ # Haml::AttributeBuilder.build_data
171
+ # Haml::AttributeBuilder.build_aria
172
+ require 'haml/haml'
173
173
  end
174
174
  end
@@ -14,7 +14,7 @@ module Haml
14
14
 
15
15
  def compile_html_comment(node, &block)
16
16
  if node.children.empty?
17
- [:html, :comment, [:static, " #{node.value[:text]} "]]
17
+ [:html, :comment, compile_text(node)]
18
18
  else
19
19
  [:html, :comment, yield(node)]
20
20
  end
@@ -28,12 +28,24 @@ module Haml
28
28
 
29
29
  content =
30
30
  if node.children.empty?
31
- [:static, " #{node.value[:text]} "]
31
+ compile_text(node)
32
32
  else
33
33
  yield(node)
34
34
  end
35
35
  [:html, :condcomment, condition, content, node.value[:revealed]]
36
36
  end
37
+
38
+ def compile_text(node)
39
+ text =
40
+ if node.value[:parse]
41
+ # Just always escaping the result for safety. We could respect
42
+ # escape_html, but I don't see any use case for it.
43
+ [:escape, true, [:dynamic, node.value[:text]]]
44
+ else
45
+ [:static, node.value[:text]]
46
+ end
47
+ [:multi, [:static, ' '], text, [:static, ' ']]
48
+ end
37
49
  end
38
50
  end
39
51
  end
data/lib/haml/engine.rb CHANGED
@@ -13,7 +13,7 @@ module Haml
13
13
  class Engine < Temple::Engine
14
14
  define_options(
15
15
  :buffer_class,
16
- generator: Temple::Generators::ArrayBuffer,
16
+ generator: Temple::Generators::StringBuffer,
17
17
  format: :html,
18
18
  attr_quote: "'",
19
19
  escape_html: true,
data/lib/haml/util.rb CHANGED
@@ -14,15 +14,15 @@ module Haml
14
14
  module Util
15
15
  extend self
16
16
 
17
- begin
18
- require 'haml/haml' # Haml::Util.escape_html
19
- rescue LoadError
20
- # For JRuby and Wasm, fallback to Ruby implementation when C extension is not available.
17
+ # For JRuby, TruffleRuby, and Wasm, fallback to Ruby implementation.
18
+ if /java|wasm/ === RUBY_PLATFORM || RUBY_ENGINE == 'truffleruby'
21
19
  require 'cgi/escape'
22
20
 
23
21
  def self.escape_html(html)
24
22
  CGI.escapeHTML(html.to_s)
25
23
  end
24
+ else
25
+ require 'haml/haml' # Haml::Util.escape_html
26
26
  end
27
27
 
28
28
  # TODO: Remove unescape_interpolation's workaround and get rid of `respond_to?`.
data/lib/haml/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Haml
3
- VERSION = '6.0.5'
3
+ VERSION = '6.0.8'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haml
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.5
4
+ version: 6.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Natalie Weizenbaum
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: exe
14
14
  cert_chain: []
15
- date: 2022-10-05 00:00:00.000000000 Z
15
+ date: 2022-10-29 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: temple