haml 6.0.4 → 6.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/REFERENCE.md +77 -1
- data/lib/haml/attribute_builder.rb +9 -9
- data/lib/haml/engine.rb +1 -0
- data/lib/haml/object_ref.rb +6 -1
- data/lib/haml/util.rb +4 -4
- data/lib/haml/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 686b38a185b57f5b0ce392e06047aa1cadff2b54a0416d1a25b88d9c6d2675d5
|
4
|
+
data.tar.gz: 77abae61a0ca3eb4d42e30e15d3dad08781f4d0566f4565ddf40ff6609370e00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d392228708c2754f52dd073839a3b13d3fd4954a04cb11547c016d3a4ee4b792ef3242328df691d834515a94a500c63b5812d017be23805a5c0a6c40e818a60b
|
7
|
+
data.tar.gz: 82262e5e10fd2392a91034ab57621e8c80cd9156be99964642403687f2c6f6409154b7dd7b1ed12a68b9fc3809058a3284ef6bfac20f11ddcc7911be487cf9b8
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
# Haml Changelog
|
2
2
|
|
3
|
+
## 6.0.6
|
4
|
+
|
5
|
+
* Prevent CRuby from accidentally using the Ruby implementation fallback
|
6
|
+
* Reversing what v6.0.3 and v6.0.4 did, but still supporting Wasm.
|
7
|
+
|
8
|
+
## 6.0.5
|
9
|
+
|
10
|
+
* Resurrect `#haml_object_ref` support in an object reference [#1097](https://github.com/haml/haml/issues/1097)
|
11
|
+
* This was removed in 6.0.0, and added back in this version.
|
12
|
+
* Stop warning `remove_whitespace: true` option.
|
13
|
+
|
3
14
|
## 6.0.4
|
4
15
|
|
5
16
|
Released on October 2, 2022
|
data/REFERENCE.md
CHANGED
@@ -81,6 +81,32 @@ You can then use it by including the `haml` gem in Ruby code, and using
|
|
81
81
|
engine = Haml::Template.new { "%p Haml code!" }
|
82
82
|
engine.render #=> "<p>Haml code!</p>\n"
|
83
83
|
|
84
|
+
### Options
|
85
|
+
|
86
|
+
Haml understands various configuration options that affect its performance and
|
87
|
+
output.
|
88
|
+
|
89
|
+
In Rails, options can be set by using `Haml::RailsTemplate.set_options` in an initializer:
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
# config/initializers/haml.rb
|
93
|
+
Haml::RailsTemplate.set_options(escape_html: false)
|
94
|
+
```
|
95
|
+
|
96
|
+
Outside Rails, you can set them by configuring them globally in `Haml::Template.options`:
|
97
|
+
|
98
|
+
```ruby
|
99
|
+
Haml::Template.options[:escape_html] = false
|
100
|
+
```
|
101
|
+
|
102
|
+
In sinatra specifically, you can set them in global config with:
|
103
|
+
```ruby
|
104
|
+
set :haml, { escape_html: false }
|
105
|
+
```
|
106
|
+
|
107
|
+
Finally, you can also set them by passing an options hash to `Haml::Engine.new` or `Haml::Template.new`.
|
108
|
+
For the complete list of available options, please see `Haml::Engine`.
|
109
|
+
|
84
110
|
## Plain Text
|
85
111
|
|
86
112
|
A substantial portion of any HTML document is its content, which is plain old
|
@@ -294,7 +320,19 @@ or using `true` and `false`:
|
|
294
320
|
%input(selected=true)
|
295
321
|
|
296
322
|
This feature works only for attributes that are included in
|
297
|
-
[`Haml::AttributeBuilder::BOOLEAN_ATTRIBUTES`](lib/haml/attribute_builder.rb)
|
323
|
+
[`Haml::AttributeBuilder::BOOLEAN_ATTRIBUTES`](lib/haml/attribute_builder.rb),
|
324
|
+
as well as `data-` and `aria-` attributes.
|
325
|
+
|
326
|
+
%input{'data-hidden' => false}
|
327
|
+
%input{'aria-hidden' => false}
|
328
|
+
%input{'xyz-hidden' => false}
|
329
|
+
|
330
|
+
will render as:
|
331
|
+
|
332
|
+
<input>
|
333
|
+
<input>
|
334
|
+
<input xyz-hidden='false'>
|
335
|
+
|
298
336
|
|
299
337
|
<!-- The title to the next section (Prefixed Attributes) has changed. This
|
300
338
|
<a> tag is so old links to here still work. -->
|
@@ -1163,6 +1201,44 @@ default. This filter is implemented using Tilt.
|
|
1163
1201
|
You can also define your own filters.
|
1164
1202
|
`Haml::Filters::YourCustomFilter#compile` should return
|
1165
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
|
+
|
1166
1242
|
See {Haml::Filters} for examples.
|
1167
1243
|
|
1168
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
|
-
|
13
|
-
|
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
|
data/lib/haml/engine.rb
CHANGED
data/lib/haml/object_ref.rb
CHANGED
@@ -6,7 +6,12 @@ module Haml
|
|
6
6
|
object, prefix = args
|
7
7
|
return {} unless object
|
8
8
|
|
9
|
-
suffix =
|
9
|
+
suffix =
|
10
|
+
if object.respond_to?(:haml_object_ref)
|
11
|
+
object.haml_object_ref
|
12
|
+
else
|
13
|
+
underscore(object.class)
|
14
|
+
end
|
10
15
|
{
|
11
16
|
'class' => [prefix, suffix].compact.join('_'),
|
12
17
|
'id' => [prefix, suffix, object.id || 'new'].compact.join('_'),
|
data/lib/haml/util.rb
CHANGED
@@ -14,15 +14,15 @@ module Haml
|
|
14
14
|
module Util
|
15
15
|
extend self
|
16
16
|
|
17
|
-
|
18
|
-
|
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
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.
|
4
|
+
version: 6.0.6
|
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-
|
15
|
+
date: 2022-10-09 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: temple
|