haml 6.1.1 → 6.1.4

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: 1c6e33698052b2d1823959741be8219446b8b3257f5124449daa8cd8deb70e4a
4
- data.tar.gz: d2a168766babc32a3f83b065e6d158e5b937995cdd5a46552fb95d4035ad5924
3
+ metadata.gz: 3d737ee35f4f57bdbbedceeb61233e0b21818fee84a50e00a1e317b2a8efcb50
4
+ data.tar.gz: 6e8a41c9e3a9e8c9db478f0c5ea636a6eb8bb2fe811b609664808edfac204645
5
5
  SHA512:
6
- metadata.gz: c6d71bcdb86f5281b34c9f56684263db88e947b17c8d79eb764b6ecb8f17945ad7fc374b2ad8032066b0c7ae52e3c0045de3658b76fc073e5ee8ab73e3c7eae3
7
- data.tar.gz: 408d9dd0b14378515d175778a9d9b472b70819c2371189aa145d2e787590213f453bba60e6dec2aee5aadf9e7bc0fd6c4b077f96676c9b6e899896ce60eb07cc
6
+ metadata.gz: b298a5a331bf81368054ac7fbae382a4ea739d9b24a8aa2db68ddf0e9595e116d3439ae75ddf73bd16dc943ee5e6fa0bdcd3f693ddf09c5abf54eaacbcfd9b14
7
+ data.tar.gz: b5ebe7e3ae7337224db692aad4c116674a6992e0880f46e96a4e9486d72bf22f57b3d1fb94396353d3b06d680387fbfb24f4dcc7ef0eb17dca4acbc7bc0336e9
@@ -22,10 +22,11 @@ jobs:
22
22
  - '2.7'
23
23
  - '3.0'
24
24
  - '3.1'
25
+ - '3.2'
25
26
  - jruby
26
27
  - truffleruby-head
27
28
  steps:
28
- - uses: actions/checkout@v2
29
+ - uses: actions/checkout@v3
29
30
  - run: sudo apt-get update && sudo apt-get install -y nodejs libxslt-dev # nodejs for execjs, libxslt for TruffleRuby nokogiri
30
31
  - name: Set up Ruby
31
32
  uses: ruby/setup-ruby@v1
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Haml Changelog
2
2
 
3
+ ## 6.1.4
4
+
5
+ * Let `Haml::Util.escape_html` use `ERB::Escape` if available [#1145](https://github.com/haml/haml/issues/1145)
6
+
7
+ ## 6.1.3
8
+
9
+ * Add `Haml::RailsTemplate#default_format` for Turbo compatibility [#1144](https://github.com/haml/haml/issues/1144)
10
+
11
+ ## 6.1.2
12
+
13
+ * Use the rails template path as `filename` [#1140](https://github.com/haml/haml/issues/1140)
14
+
3
15
  ## 6.1.1
4
16
 
5
17
  * Fix an empty output of Ruby 3.1's Hash shorthand syntax [#1083](https://github.com/haml/haml/issues/1083)
@@ -100,6 +112,14 @@ Released on September 21, 2022
100
112
  * Removed: `block_is_haml?`, `capture_haml`, `escape_once`, `find_and_preserve`, `flatten`, `haml_concat`,
101
113
  `haml_indent`, `haml_tag`, `haml_tag_if`, `html_attrs`, `html_escape`, `init_haml_helpers`, `is_haml?`,
102
114
  `list_of`, `non_haml`, `precede`, `succeed`, `surround`, `tab_down`, `tab_up`, `with_tabs`
115
+ * `:ruby` filter
116
+ * Removed: `haml_io`
117
+ * Alternatives to the removed helpers:
118
+ * Some simple ones could work by copying [the original definition](https://github.com/haml/haml/blob/v5.2.2/lib/haml/helpers.rb).
119
+ * For helpers generating general HTML tags, also consider using what your framework provides, e.g. Rails `content_tag`.
120
+ Same applies to `capture_haml`, e.g. Rails `capture`.
121
+ * Ones that rely on `Haml::Buffer` have no direct alternative by design. They existed at the cost of performance.
122
+ You need to define a helper, instantiate a String buffer in it, append stuff to it, and call it inside `=`.
103
123
  * Only the following attributes and `aria`/`data` attributes are considered boolean attributes:
104
124
  * `allowfullscreen`, `async`, `autobuffer`, `autofocus`, `autoplay`, `checked`, `controls`, `default`,
105
125
  `defer`, `disabled`, `download`, `formnovalidate`, `hidden`, `inert`, `ismap`, `itemscope`, `loop`,
data/Gemfile CHANGED
@@ -21,3 +21,7 @@ else
21
21
  gem 'stackprof'
22
22
  end
23
23
  end
24
+
25
+ if RUBY_VERSION < '2.6'
26
+ gem 'rake-compiler', '< 1.2.4'
27
+ end
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![Gem Version](https://badge.fury.io/rb/haml.svg)](http://rubygems.org/gems/haml)
4
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
- [![Inline docs](http://inch-ci.org/github/haml/haml.png)](http://inch-ci.org/github/haml/haml)
6
+ [![Inline docs](https://inch-ci.org/github/haml/haml.svg)](https://inch-ci.org/github/haml/haml)
7
7
 
8
8
  Haml is a templating engine for HTML. It's designed to make it both easier and
9
9
  more pleasant to write HTML documents, by eliminating redundancy, reflecting the
data/REFERENCE.md CHANGED
@@ -180,10 +180,10 @@ closing tags for any element.
180
180
 
181
181
  ### Attributes: `{}` or `()` {#attributes}
182
182
 
183
- Brackets represent a Ruby hash that is used for specifying the attributes of an
183
+ Braces represent a Ruby hash that is used for specifying the attributes of an
184
184
  element. It is literally evaluated as a Ruby hash, so logic will work in it and
185
185
  local variables may be used. Quote characters within the attribute will be
186
- replaced by appropriate escape sequences. The hash is placed after the tag is
186
+ replaced with appropriate escape sequences. The hash is placed after the tag is
187
187
  defined. For example:
188
188
 
189
189
  %html{:xmlns => "http://www.w3.org/1999/xhtml", "xml:lang" => "en", :lang => "en"}
@@ -247,7 +247,7 @@ could render as either of:
247
247
  #### HTML-style Attributes: `()`
248
248
 
249
249
  Haml also supports a terser, less Ruby-specific attribute syntax based on HTML's
250
- attributes. These are used with parentheses instead of brackets, like so:
250
+ attributes. These are used with parentheses instead of braces, like so:
251
251
 
252
252
  %html(xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en")
253
253
 
@@ -320,7 +320,7 @@ or using `true` and `false`:
320
320
  %input(selected=true)
321
321
 
322
322
  This feature works only for attributes that are included in
323
- [`Haml::AttributeBuilder::BOOLEAN_ATTRIBUTES`](lib/haml/attribute_builder.rb),
323
+ [`Haml::AttributeBuilder::BOOLEAN_ATTRIBUTES`](https://github.com/haml/haml/blob/main/lib/haml/attribute_builder.rb#L5),
324
324
  as well as `data-` and `aria-` attributes.
325
325
 
326
326
  %input{'data-hidden' => false}
@@ -360,7 +360,7 @@ will render as:
360
360
 
361
361
  <a data-author-id='123' data-category='7' href='/posts'>Posts By Author</a>
362
362
 
363
- Notice that the underscore in `author_id` was replaced by a hyphen. If you wish
363
+ Notice that the underscore in `author_id` was replaced with a hyphen. If you wish
364
364
  to suppress this behavior, you can set Haml's
365
365
  {Haml::Options#hyphenate_data_attrs `:hyphenate_data_attrs` option} to `false`,
366
366
  and the output will be rendered as:
@@ -992,7 +992,7 @@ most code but you may have errors with code like the following:
992
992
 
993
993
  %span #{'{'}
994
994
 
995
- This code will generate a syntax error, complaining about unbalanced brackets.
995
+ This code will generate a syntax error, complaining about unbalanced braces.
996
996
  In cases like this, the recommended workaround is output the code as a Ruby
997
997
  string to force Haml to parse the code with Ruby.
998
998
 
@@ -1093,7 +1093,7 @@ uses to implement many of its filters:
1093
1093
 
1094
1094
  Tilt.prefer Tilt::RedCarpetTemplate
1095
1095
 
1096
- See the [Tilt documentation](https://github.com/rtomayko/tilt#fallback-mode) for
1096
+ See the [Tilt documentation](https://github.com/rtomayko/tilt) for
1097
1097
  more info.
1098
1098
 
1099
1099
  Haml comes with the following filters defined:
@@ -1145,7 +1145,7 @@ implemented using Tilt.
1145
1145
 
1146
1146
  ### `:maruku` {#maruku-filter}
1147
1147
 
1148
- Parses the filtered text with [Maruku](https://github.com/nex3/maruku), which
1148
+ Parses the filtered text with [Maruku](https://github.com/bhollis/maruku), which
1149
1149
  has some non-standard extensions to Markdown.
1150
1150
 
1151
1151
  As of Haml 4.0, this filter is defined in [Haml
@@ -1168,11 +1168,8 @@ HTML escape code for newlines, to preserve nice-looking output. See also
1168
1168
 
1169
1169
  ### `:ruby` {#ruby-filter}
1170
1170
 
1171
- Parses the filtered text with the normal Ruby interpreter. Creates an `IO`
1172
- object named `haml_io`, anything written to it is output into the Haml document.
1173
- Not available if the {Haml::Options#suppress_eval `:suppress_eval`} option is
1174
- set to true. The Ruby code is evaluated in the same context as the Haml
1175
- template.
1171
+ Parses the filtered text with the normal Ruby interpreter.
1172
+ The Ruby code is evaluated in the same context as the Haml template.
1176
1173
 
1177
1174
  ### `:sass` {#sass-filter}
1178
1175
 
@@ -1213,7 +1210,7 @@ end
1213
1210
  Haml::Filters.registered[:hello] ||= HelloFilter
1214
1211
  ```
1215
1212
 
1216
- A more complex complex example
1213
+ A more complex example:
1217
1214
 
1218
1215
  ```ruby
1219
1216
  class BetterFilter < Haml::Filters::Base
@@ -1285,7 +1282,7 @@ can be wrapped over multiple lines,
1285
1282
  as long as each line but the last ends in a comma
1286
1283
  (see [Inserting Ruby](#inserting_ruby)).
1287
1284
 
1288
- ## Whitespace Preservation
1285
+ ## Whitespace Preservation {#whitespace_preservation}
1289
1286
 
1290
1287
  Sometimes you don't want Haml to indent all your text.
1291
1288
  For example, tags like `pre` and `textarea` are whitespace-sensitive;
data/ext/haml/haml.c CHANGED
@@ -77,12 +77,6 @@ escape_attribute(VALUE escape_attrs, VALUE str)
77
77
  }
78
78
  }
79
79
 
80
- static VALUE
81
- rb_escape_html(RB_UNUSED_VAR(VALUE self), VALUE value)
82
- {
83
- return escape_html(to_s(value));
84
- }
85
-
86
80
  static VALUE
87
81
  haml_build_id(VALUE escape_attrs, VALUE values)
88
82
  {
@@ -504,14 +498,12 @@ rb_haml_build(int argc, VALUE *argv, RB_UNUSED_VAR(VALUE self))
504
498
  void
505
499
  Init_haml(void)
506
500
  {
507
- VALUE mHaml, mUtil;
501
+ VALUE mHaml;
508
502
 
509
503
  mHaml = rb_define_module("Haml");
510
504
  mObjectRef = rb_define_module_under(mHaml, "ObjectRef");
511
- mUtil = rb_define_module_under(mHaml, "Util");
512
505
  mAttributeBuilder = rb_define_module_under(mHaml, "AttributeBuilder");
513
506
 
514
- rb_define_singleton_method(mUtil, "escape_html", rb_escape_html, 1);
515
507
  rb_define_singleton_method(mAttributeBuilder, "build", rb_haml_build, -1);
516
508
  rb_define_singleton_method(mAttributeBuilder, "build_id", rb_haml_build_id, -1);
517
509
  rb_define_singleton_method(mAttributeBuilder, "build_class", rb_haml_build_class, -1);
data/haml.gemspec CHANGED
@@ -19,6 +19,8 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ['lib']
21
21
 
22
+ spec.metadata = { 'rubygems_mfa_required' => 'true' }
23
+
22
24
  if /java/ === RUBY_PLATFORM
23
25
  spec.platform = 'java'
24
26
  else
@@ -27,6 +27,11 @@ module Haml
27
27
  source ||= template.source
28
28
  options = RailsTemplate.options
29
29
 
30
+ # Make the filename available in parser etc.
31
+ if template.respond_to?(:identifier)
32
+ options = options.merge(filename: template.identifier)
33
+ end
34
+
30
35
  # https://github.com/haml/haml/blob/4.0.7/lib/haml/template/plugin.rb#L19-L20
31
36
  # https://github.com/haml/haml/blob/4.0.7/lib/haml/options.rb#L228
32
37
  if template.respond_to?(:type) && template.type == 'text/xml'
@@ -43,6 +48,11 @@ module Haml
43
48
  Engine.new(options).call(source)
44
49
  end
45
50
 
51
+ # Rails Turbo looks for this
52
+ def default_format
53
+ :html
54
+ end
55
+
46
56
  def supports_streaming?
47
57
  RailsTemplate.options[:streaming]
48
58
  end
data/lib/haml/util.rb CHANGED
@@ -14,15 +14,16 @@ module Haml
14
14
  module Util
15
15
  extend self
16
16
 
17
- # For JRuby, TruffleRuby, and Wasm, fallback to Ruby implementation.
18
- if /java|wasm/ === RUBY_PLATFORM || RUBY_ENGINE == 'truffleruby'
17
+ begin # Ruby 3.2+ or ERB 4+
18
+ require 'erb/escape'
19
+
20
+ define_singleton_method(:escape_html, ERB::Escape.instance_method(:html_escape))
21
+ rescue LoadError
19
22
  require 'cgi/escape'
20
23
 
21
24
  def self.escape_html(html)
22
25
  CGI.escapeHTML(html.to_s)
23
26
  end
24
- else
25
- require 'haml/haml' # Haml::Util.escape_html
26
27
  end
27
28
 
28
29
  # 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.1.1'
3
+ VERSION = '6.1.4'
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.1.1
4
+ version: 6.1.4
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-12-10 00:00:00.000000000 Z
15
+ date: 2023-09-27 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: temple
@@ -339,7 +339,8 @@ files:
339
339
  homepage: https://haml.info
340
340
  licenses:
341
341
  - MIT
342
- metadata: {}
342
+ metadata:
343
+ rubygems_mfa_required: 'true'
343
344
  post_install_message:
344
345
  rdoc_options: []
345
346
  require_paths:
@@ -355,7 +356,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
355
356
  - !ruby/object:Gem::Version
356
357
  version: '0'
357
358
  requirements: []
358
- rubygems_version: 3.4.0.dev
359
+ rubygems_version: 3.4.10
359
360
  signing_key:
360
361
  specification_version: 4
361
362
  summary: An elegant, structured (X)HTML/XML templating engine.