haml 6.0.1 → 6.0.2

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: 909d5636fba736ef06747221b4d0ff34a8c5b850f2c8d4cc60ac27843e914e94
4
- data.tar.gz: 478fd2cce0e05e386690aa83fa41132da006cb02437ec43a0b4882842a2e973c
3
+ metadata.gz: 5154c2aa8152311d83ac1c3acb9123d31b3b24af570334c2b9786bc8c057b5b7
4
+ data.tar.gz: 55cf78c93ff92aea7794b8f12a96bdff471759d072d1b5c0689c8dc9ee4fee5b
5
5
  SHA512:
6
- metadata.gz: 268bfdc33ba76950ab553692c5ff1c45b84a3f3b4185248a19c6a3a74f4b47cd46527d279ed3782f9b7fd6bba6be889a531b7e6c133a4f00ac7e3e06d61a464c
7
- data.tar.gz: 1b4f559abe65e3c39627d87b6cc2da894ca67514f62d702ff0920d9d974dda49d4ab7b49e465157622b31a9c3ad5b1925e5e4aa2b1360640d784a7a6f537178a
6
+ metadata.gz: ef8aa686f64c59b24b72c907a8dafb6cad0c060000094c74c2db73c1d7155a412937d64f6d377b1fa66eaa5126f694a40e7222593da8c71de360a4f2025098bc
7
+ data.tar.gz: 1d3c797b5925f1b1b3721b4f14c4756ba102042079b8c091a8b079e9f3ea7de8b1fefd8d5d724f5f111f1d7b9e77cbac77280cf9abc78782ce600549e35389ec
data/.yardopts ADDED
@@ -0,0 +1,19 @@
1
+ --charset utf-8
2
+ --readme README.md
3
+ --markup markdown
4
+ --markup-provider kramdown
5
+ --template-path yard
6
+ --default-return ""
7
+ --title "Haml Documentation"
8
+ --query 'object.type != :classvariable'
9
+ --query 'object.type != :constant || @api && @api.text == "public"'
10
+ --exclude lib/haml/railtie.rb
11
+ --hide-void-return
12
+ --protected
13
+ --no-private
14
+ --no-highlight
15
+ -
16
+ FAQ.md
17
+ CHANGELOG.md
18
+ REFERENCE.md
19
+ MIT-LICENSE
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Haml Changelog
2
2
 
3
+ ## 6.0.2
4
+
5
+ Released on September 28, 2022
6
+ ([diff](https://github.com/haml/haml/compare/v6.0.1...v6.0.2)).
7
+
8
+ * Unescape HTML-safe arguments for `surround`, `succeed`, and `precede` on Rails
9
+ [#1088](https://github.com/haml/haml/issues/1088)
10
+
3
11
  ## 6.0.1
4
12
 
5
13
  Released on September 23, 2022
@@ -17,7 +25,12 @@ Released on September 21, 2022
17
25
  * Haml 6 is about 1.7x faster than Haml 5 in [this benchmark](benchmark/slim/run-benchmarks.rb).
18
26
  * The parser is kept as is, but everything else is replaced.
19
27
  * The `haml` CLI interface was also replaced.
20
- * All Haml helpers except for `preserve` are removed.
28
+ * The interface of `Haml::Engine` is changed. `Haml::Template` is most likely what you need now.
29
+ * Most Haml helpers are removed.
30
+ * On Rails, only `find_and_reserve`, `preserve`, `surround`, `precede`, `succeed`, and `capture_haml` are left.
31
+ * On Tilt, only `preserve` is left.
32
+ * Only the attributes in [`Haml::AttributeBuilder::BOOLEAN_ATTRIBUTES`](lib/haml/attribute_builder.rb)
33
+ are handled as boolean attributes.
21
34
  * Some legacy Rails integration is removed.
22
35
 
23
36
  ## 5.2.2
data/README.md CHANGED
@@ -22,7 +22,7 @@ gem install haml
22
22
  After you write some Haml, you can run
23
23
 
24
24
  ~~~sh
25
- haml document.haml
25
+ haml render document.haml
26
26
  ~~~
27
27
 
28
28
  to compile it to HTML. For more information on these commands, check out
@@ -41,8 +41,8 @@ To use Haml with Rails, simply add Haml to your Gemfile and run `bundle`.
41
41
  gem 'haml'
42
42
  ~~~
43
43
 
44
- If you'd like to replace Rails's Erb-based generators with Haml, add
45
- [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.
46
46
 
47
47
  ## Formatting
48
48
 
data/REFERENCE.md CHANGED
@@ -30,7 +30,7 @@ The first step for all of these is to install the Haml gem:
30
30
 
31
31
  To run Haml from the command line, just use
32
32
 
33
- haml input.haml output.html
33
+ haml render input.haml > output.html
34
34
 
35
35
  Use `haml --help` for full documentation.
36
36
 
@@ -68,24 +68,6 @@ may be compiled to:
68
68
  </div>
69
69
  </div>
70
70
 
71
- ### Rails XSS Protection
72
-
73
- Haml supports Rails' XSS protection scheme, which was introduced in Rails 2.3.5+
74
- and is enabled by default in 3.0.0+. If it's enabled, Haml's
75
- {Haml::Options#escape_html `:escape_html`} option is set to `true` by default -
76
- like in ERB, all strings printed to a Haml template are escaped by default. Also
77
- like ERB, strings marked as HTML safe are not escaped. Haml also has [its own
78
- syntax for printing a raw string to the template](#unescaping_html).
79
-
80
- If the `:escape_html` option is set to false when XSS protection is enabled,
81
- Haml doesn't escape Ruby strings by default. However, if a string marked
82
- HTML-safe is passed to [Haml's escaping syntax](#escaping_html), it won't be
83
- escaped.
84
-
85
- Finally, all the {Haml::Helpers Haml helpers} that return strings that are known
86
- to be HTML safe are marked as such. In addition, string input is escaped unless
87
- it's HTML safe.
88
-
89
71
  ### Ruby Module
90
72
 
91
73
  Haml can also be used completely separately from Rails and ActionView. To do
@@ -93,62 +75,12 @@ this, install the gem with RubyGems:
93
75
 
94
76
  gem install haml
95
77
 
96
- You can then use it by including the "haml" gem in Ruby code, and using
97
- {Haml::Engine} like so:
78
+ You can then use it by including the `haml` gem in Ruby code, and using
79
+ {Haml::Template} like so:
98
80
 
99
- engine = Haml::Engine.new("%p Haml code!")
81
+ engine = Haml::Template.new { "%p Haml code!" }
100
82
  engine.render #=> "<p>Haml code!</p>\n"
101
83
 
102
- ### Options
103
-
104
- Haml understands various configuration options that affect its performance and
105
- output.
106
-
107
- In Rails, options can be set by setting the {Haml::Template#options Haml::Template.options}
108
- hash in an initializer:
109
-
110
- ```ruby
111
- # config/initializers/haml.rb
112
- Haml::Template.options[:format] = :html5
113
-
114
- # Avoid escaping attributes which are already escaped
115
- Haml::Template.options[:escape_attrs] = :once
116
- ```
117
-
118
- Outside Rails, you can set them by configuring them globally in
119
- Haml::Options.defaults:
120
-
121
- ```ruby
122
- Haml::Options.defaults[:format] = :html5
123
- ```
124
-
125
- In sinatra specifically, you can set them in global config with:
126
- ```ruby
127
- set :haml, { escape_html: true }
128
- ```
129
-
130
- Finally, you can also set them by passing an options hash to
131
- {Haml::Engine#initialize}. For the complete list of available options, please
132
- see {Haml::Options}.
133
-
134
- ### Encodings
135
-
136
- Haml supports the same sorts of
137
- encoding-declaration comments that Ruby does. Although both Ruby and Haml
138
- support several different styles, the easiest it just to add `-# coding:
139
- encoding-name` at the beginning of the Haml template (it must come before all
140
- other lines). This will tell Haml that the template is encoded using the named
141
- encoding.
142
-
143
- By default, the HTML generated by Haml has the same encoding as the Haml
144
- template. However, if `Encoding.default_internal` is set, Haml will attempt to
145
- use that instead. In addition, the {Haml::Options#encoding `:encoding` option}
146
- can be used to specify an output encoding manually.
147
-
148
- Note that, like Ruby, Haml does not support templates encoded in UTF-16 or
149
- UTF-32, since these encodings are not compatible with ASCII. It is possible to
150
- use these as the output encoding, though.
151
-
152
84
  ## Plain Text
153
85
 
154
86
  A substantial portion of any HTML document is its content, which is plain old
@@ -325,49 +257,6 @@ Haml also supports Ruby's new hash syntax:
325
257
 
326
258
  %a{title: @title, href: href} Stuff
327
259
 
328
- #### Attribute Methods
329
-
330
- A Ruby method call that returns a hash can be substituted for the hash contents.
331
- For example, {Haml::Helpers} defines the following method:
332
-
333
- def html_attrs(lang = 'en-US')
334
- {:xmlns => "http://www.w3.org/1999/xhtml", 'xml:lang' => lang, :lang => lang}
335
- end
336
-
337
- This can then be used in Haml, like so:
338
-
339
- %html{html_attrs('fr-fr')}
340
-
341
- This is compiled to:
342
-
343
- <html lang='fr-fr' xml:lang='fr-fr' xmlns='http://www.w3.org/1999/xhtml'>
344
- </html>
345
-
346
- You can use as many such attribute methods as you want by separating them with
347
- commas, like a Ruby argument list. All the hashes will be merged together, from
348
- left to right. For example, if you defined
349
-
350
- def hash1
351
- {:bread => 'white', :filling => 'peanut butter and jelly'}
352
- end
353
-
354
- def hash2
355
- {:bread => 'whole wheat'}
356
- end
357
-
358
- then
359
-
360
- %sandwich{hash1, hash2, :delicious => 'true'}/
361
-
362
- would compile to:
363
-
364
- <sandwich bread='whole wheat' delicious='true' filling='peanut butter and jelly' />
365
-
366
- Note that the Haml attributes list has the same syntax as a Ruby method call.
367
- This means that any attribute methods must come before the hash literal.
368
-
369
- Attribute methods aren't supported for HTML-style attributes.
370
-
371
260
  #### Boolean Attributes
372
261
 
373
262
  Some attributes, such as "checked" for `input` tags or "selected" for `option`
@@ -404,6 +293,9 @@ or using `true` and `false`:
404
293
 
405
294
  %input(selected=true)
406
295
 
296
+ This feature works only for attributes that are included in
297
+ [`Haml::AttributeBuilder::BOOLEAN_ATTRIBUTES`](lib/haml/attribute_builder.rb).
298
+
407
299
  <!-- The title to the next section (Prefixed Attributes) has changed. This
408
300
  <a> tag is so old links to here still work. -->
409
301
  <a id="html5_custom_data_attributes" style="border:0;"></a>
@@ -993,7 +885,7 @@ is compiled to:
993
885
 
994
886
  ### Whitespace Preservation: `~` {#tilde}
995
887
 
996
- `~` works just like `=`, except that it runs {Haml::Helpers#find\_and\_preserve}
888
+ `~` works just like `=`, except that it runs {Haml::Helpers.preserve}
997
889
  on its input. For example,
998
890
 
999
891
  ~ "Foo\n<pre>Bar\nBaz</pre>"
@@ -1154,9 +1046,6 @@ is compiled to
1154
1046
  <p>I <strong>really</strong> prefer <em>raspberry</em> jam.</p>
1155
1047
  </div>
1156
1048
 
1157
- Note that `#{}` interpolation within filters is HTML-escaped if you specify true to
1158
- {Haml::Options#escape_filter_interpolations `:escape_filter_interpolations`} option.
1159
-
1160
1049
  The functionality of some filters such as Markdown can be provided by many
1161
1050
  different libraries. Usually you don't have to worry about this - you can just
1162
1051
  load the gem of your choice and Haml will automatically use it.
@@ -1271,43 +1160,10 @@ default. This filter is implemented using Tilt.
1271
1160
 
1272
1161
  ### Custom Filters
1273
1162
 
1274
- You can also define your own filters. See {Haml::Filters} for details.
1275
-
1276
- ## Helper Methods {#helper-methods}
1277
-
1278
- Sometimes you need to manipulate whitespace in a more precise fashion than what
1279
- the whitespace removal methods allow. There are a few helper methods that are
1280
- useful when dealing with inline content. All these methods take a Haml block to
1281
- modify.
1282
-
1283
- ### surround {#surround}
1284
-
1285
- Surrounds a Haml block with text. Expects 1 or 2 string arguments used to
1286
- surround the Haml block. If a second argument is not provided, the first
1287
- argument is used as the second.
1288
-
1289
- = surround "(", ")" do
1290
- = link_to "learn more", "#"
1291
-
1292
- ### precede {#precede}
1293
-
1294
- Prepends a Haml block with text. Expects 1 argument.
1295
-
1296
- = precede "*" do
1297
- %span Required
1298
-
1299
- ### succeed {#succeed}
1300
-
1301
- Appends a Haml block with text. Expects 1 argument.
1302
-
1303
- Begin by
1304
- = succeed "," do
1305
- = link_to "filling out your profile", "#"
1306
- = succeed "," do
1307
- = link_to "adding a bio", "#"
1308
- and
1309
- = succeed "." do
1310
- = link_to "inviting friends", "#"
1163
+ You can also define your own filters.
1164
+ `Haml::Filters::YourCustomFilter#compile` should return
1165
+ [a Temple expression](https://github.com/judofyr/temple/blob/master/EXPRESSIONS.md).
1166
+ See {Haml::Filters} for examples.
1311
1167
 
1312
1168
  ## Multiline: `|` {#multiline}
1313
1169
 
@@ -1367,14 +1223,7 @@ Haml won't try to re-format the indentation.
1367
1223
  Literal `textarea` and `pre` tags automatically preserve content given through
1368
1224
  `=`. Dynamically-generated `textarea`s and `pre`s can't be preserved
1369
1225
  automatically, and so should be passed through
1370
- {Haml::Helpers#find\_and\_preserve} or the [`~` command](#tilde), which has the
1226
+ {Haml::Helpers.preserve} or the [`~` command](#tilde), which has the
1371
1227
  same effect.
1372
1228
 
1373
1229
  Blocks of literal text can be preserved using the [`:preserve` filter](#preserve-filter).
1374
-
1375
- ## Helpers
1376
-
1377
- Haml offers a bunch of helpers that are useful for doing stuff like preserving
1378
- whitespace, creating nicely indented output for user-defined helpers, and other
1379
- useful things. The helpers are all documented in the {Haml::Helpers} and
1380
- {Haml::Helpers::ActionViewExtensions} modules.
data/Rakefile CHANGED
@@ -112,5 +112,30 @@ task bench: :compile do
112
112
  exit system(*cmd)
113
113
  end
114
114
 
115
+ namespace :doc do
116
+ task :sass do
117
+ require 'sass'
118
+ Dir["yard/default/**/*.sass"].each do |sass|
119
+ File.open(sass.gsub(/sass$/, 'css'), 'w') do |f|
120
+ f.write(Sass::Engine.new(File.read(sass)).render)
121
+ end
122
+ end
123
+ end
124
+
125
+ desc "List all undocumented methods and classes."
126
+ task :undocumented do
127
+ command = 'yard --list --query '
128
+ command << '"object.docstring.blank? && '
129
+ command << '!(object.type == :method && object.is_alias?)"'
130
+ sh command
131
+ end
132
+ end
133
+
134
+ desc "Generate documentation"
135
+ task(:doc => 'doc:sass') {sh "yard"}
136
+
137
+ desc "Generate documentation incrementally"
138
+ task(:redoc) {sh "yard -c"}
139
+
115
140
  task default: %w[compile hamlit:test]
116
141
  task test: %w[compile test:all]
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: false
2
2
  require 'haml/helpers'
3
3
 
4
- # Currently this Haml::Helpers depends on
5
- # ActionView internal implementation. (not desired)
4
+ # There are only helpers that depend on ActionView internals.
6
5
  module Haml
7
6
  module RailsHelpers
8
7
  include Helpers
@@ -32,16 +31,19 @@ module Haml
32
31
 
33
32
  def surround(front, back = front, &block)
34
33
  output = capture_haml(&block)
35
-
36
- "#{escape_once(front)}#{output.chomp}#{escape_once(back)}\n".html_safe
34
+ front = escape_once(front) unless front.html_safe?
35
+ back = escape_once(back) unless back.html_safe?
36
+ "#{front}#{output.chomp}#{back}\n".html_safe
37
37
  end
38
38
 
39
39
  def precede(str, &block)
40
- "#{escape_once(str)}#{capture_haml(&block).chomp}\n".html_safe
40
+ str = escape_once(str) unless str.html_safe?
41
+ "#{str}#{capture_haml(&block).chomp}\n".html_safe
41
42
  end
42
43
 
43
44
  def succeed(str, &block)
44
- "#{capture_haml(&block).chomp}#{escape_once(str)}\n".html_safe
45
+ str = escape_once(str) unless str.html_safe?
46
+ "#{capture_haml(&block).chomp}#{str}\n".html_safe
45
47
  end
46
48
 
47
49
  def capture_haml(*args, &block)
data/lib/haml/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Haml
3
- VERSION = '6.0.1'
3
+ VERSION = '6.0.2'
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.1
4
+ version: 6.0.2
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-09-23 00:00:00.000000000 Z
15
+ date: 2022-09-28 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: temple
@@ -265,6 +265,7 @@ files:
265
265
  - ".github/FUNDING.yml"
266
266
  - ".github/workflows/test.yml"
267
267
  - ".gitignore"
268
+ - ".yardopts"
268
269
  - CHANGELOG.md
269
270
  - FAQ.md
270
271
  - Gemfile