haml 4.0.7 → 5.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.github/workflows/test.yml +36 -0
- data/.gitignore +19 -0
- data/.gitmodules +3 -0
- data/.yardopts +2 -3
- data/CHANGELOG.md +146 -4
- data/FAQ.md +4 -14
- data/Gemfile +16 -0
- data/MIT-LICENSE +2 -2
- data/README.md +90 -47
- data/REFERENCE.md +160 -74
- data/Rakefile +44 -63
- data/TODO +24 -0
- data/benchmark.rb +70 -0
- data/haml.gemspec +45 -0
- data/lib/haml/.gitattributes +1 -0
- data/lib/haml/attribute_builder.rb +219 -0
- data/lib/haml/attribute_compiler.rb +237 -0
- data/lib/haml/attribute_parser.rb +150 -0
- data/lib/haml/buffer.rb +12 -175
- data/lib/haml/compiler.rb +110 -320
- data/lib/haml/engine.rb +34 -41
- data/lib/haml/error.rb +28 -24
- data/lib/haml/escapable.rb +77 -0
- data/lib/haml/exec.rb +38 -20
- data/lib/haml/filters.rb +22 -27
- data/lib/haml/generator.rb +42 -0
- data/lib/haml/helpers/action_view_extensions.rb +4 -2
- data/lib/haml/helpers/action_view_mods.rb +45 -60
- data/lib/haml/helpers/action_view_xss_mods.rb +2 -0
- data/lib/haml/helpers/safe_erubi_template.rb +20 -0
- data/lib/haml/helpers/safe_erubis_template.rb +5 -1
- data/lib/haml/helpers/xss_mods.rb +23 -13
- data/lib/haml/helpers.rb +134 -89
- data/lib/haml/options.rb +63 -69
- data/lib/haml/parser.rb +319 -227
- data/lib/haml/plugin.rb +54 -0
- data/lib/haml/railtie.rb +43 -12
- data/lib/haml/sass_rails_filter.rb +18 -4
- data/lib/haml/template/options.rb +13 -2
- data/lib/haml/template.rb +13 -6
- data/lib/haml/temple_engine.rb +124 -0
- data/lib/haml/temple_line_counter.rb +30 -0
- data/lib/haml/util.rb +83 -202
- data/lib/haml/version.rb +3 -1
- data/lib/haml.rb +2 -0
- data/yard/default/.gitignore +1 -0
- data/yard/default/fulldoc/html/css/common.sass +15 -0
- data/yard/default/layout/html/footer.erb +12 -0
- metadata +73 -115
- data/lib/haml/template/plugin.rb +0 -41
- data/test/engine_test.rb +0 -2013
- data/test/erb/_av_partial_1.erb +0 -12
- data/test/erb/_av_partial_2.erb +0 -8
- data/test/erb/action_view.erb +0 -62
- data/test/erb/standard.erb +0 -55
- data/test/filters_test.rb +0 -254
- data/test/gemfiles/Gemfile.rails-3.0.x +0 -5
- data/test/gemfiles/Gemfile.rails-3.1.x +0 -6
- data/test/gemfiles/Gemfile.rails-3.2.x +0 -5
- data/test/gemfiles/Gemfile.rails-4.0.x +0 -5
- data/test/haml-spec/LICENSE +0 -14
- data/test/haml-spec/README.md +0 -106
- data/test/haml-spec/lua_haml_spec.lua +0 -38
- data/test/haml-spec/perl_haml_test.pl +0 -81
- data/test/haml-spec/ruby_haml_test.rb +0 -23
- data/test/haml-spec/tests.json +0 -660
- data/test/helper_test.rb +0 -583
- data/test/markaby/standard.mab +0 -52
- data/test/mocks/article.rb +0 -6
- data/test/parser_test.rb +0 -105
- data/test/results/content_for_layout.xhtml +0 -12
- data/test/results/eval_suppressed.xhtml +0 -9
- data/test/results/helpers.xhtml +0 -70
- data/test/results/helpful.xhtml +0 -10
- data/test/results/just_stuff.xhtml +0 -70
- data/test/results/list.xhtml +0 -12
- data/test/results/nuke_inner_whitespace.xhtml +0 -40
- data/test/results/nuke_outer_whitespace.xhtml +0 -148
- data/test/results/original_engine.xhtml +0 -20
- data/test/results/partial_layout.xhtml +0 -5
- data/test/results/partial_layout_erb.xhtml +0 -5
- data/test/results/partials.xhtml +0 -21
- data/test/results/render_layout.xhtml +0 -3
- data/test/results/silent_script.xhtml +0 -74
- data/test/results/standard.xhtml +0 -162
- data/test/results/tag_parsing.xhtml +0 -23
- data/test/results/very_basic.xhtml +0 -5
- data/test/results/whitespace_handling.xhtml +0 -90
- data/test/template_test.rb +0 -354
- data/test/templates/_av_partial_1.haml +0 -9
- data/test/templates/_av_partial_1_ugly.haml +0 -9
- data/test/templates/_av_partial_2.haml +0 -5
- data/test/templates/_av_partial_2_ugly.haml +0 -5
- data/test/templates/_layout.erb +0 -3
- data/test/templates/_layout_for_partial.haml +0 -3
- data/test/templates/_partial.haml +0 -8
- data/test/templates/_text_area.haml +0 -3
- data/test/templates/_text_area_helper.html.haml +0 -4
- data/test/templates/action_view.haml +0 -47
- data/test/templates/action_view_ugly.haml +0 -47
- data/test/templates/breakage.haml +0 -8
- data/test/templates/content_for_layout.haml +0 -8
- data/test/templates/eval_suppressed.haml +0 -11
- data/test/templates/helpers.haml +0 -55
- data/test/templates/helpful.haml +0 -11
- data/test/templates/just_stuff.haml +0 -85
- data/test/templates/list.haml +0 -12
- data/test/templates/nuke_inner_whitespace.haml +0 -32
- data/test/templates/nuke_outer_whitespace.haml +0 -144
- data/test/templates/original_engine.haml +0 -17
- data/test/templates/partial_layout.haml +0 -3
- data/test/templates/partial_layout_erb.erb +0 -4
- data/test/templates/partialize.haml +0 -1
- data/test/templates/partials.haml +0 -12
- data/test/templates/render_layout.haml +0 -2
- data/test/templates/silent_script.haml +0 -45
- data/test/templates/standard.haml +0 -43
- data/test/templates/standard_ugly.haml +0 -43
- data/test/templates/tag_parsing.haml +0 -21
- data/test/templates/very_basic.haml +0 -4
- data/test/templates/whitespace_handling.haml +0 -87
- data/test/test_helper.rb +0 -81
- data/test/util_test.rb +0 -63
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: ec6cbb2e4023f397f1d7b6d84f06d78ab492a61e88c3f16496f39d0baeb47a83
|
|
4
|
+
data.tar.gz: 004c2dd34697cb61a8c12854bf4b99abb3cab5195f28922b813ee299225e7663
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a7430b4e42cf809f847448a9e04623b4b58878e44facedef5e43714820e8068f0bb853772564d5545936cdad8346f0c33abfc11642a3737d91c9a1f6242b3e41
|
|
7
|
+
data.tar.gz: 8a91df0cb185014512ee473a21755ba41edb06e835b29740e8e46c76287a81405b2706d8a10ea148893a9429de306c67584ac1c286637c0812a5562cf149431b
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
name: test
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches:
|
|
5
|
+
- main
|
|
6
|
+
pull_request:
|
|
7
|
+
types:
|
|
8
|
+
- opened
|
|
9
|
+
- synchronize
|
|
10
|
+
- reopened
|
|
11
|
+
jobs:
|
|
12
|
+
test:
|
|
13
|
+
name: 'Ruby: ${{ matrix.ruby }}, Rails: ${{ matrix.rails }}'
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
strategy:
|
|
16
|
+
fail-fast: false
|
|
17
|
+
matrix:
|
|
18
|
+
ruby: [2.6, 2.7, 3.0, jruby-9.2]
|
|
19
|
+
rails: [5.2.x, 6.0.x, 6.1.x, rails-edge]
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@v2
|
|
22
|
+
- name: Set up Ruby
|
|
23
|
+
uses: ruby/setup-ruby@v1
|
|
24
|
+
with:
|
|
25
|
+
ruby-version: ${{ matrix.ruby }}
|
|
26
|
+
- uses: actions/cache@v2
|
|
27
|
+
with:
|
|
28
|
+
path: vendor/bundle
|
|
29
|
+
key: ${{ runner.os }}-${{ matrix.ruby }}-gems-${{ hashFiles('**/Gemfile.lock') }}
|
|
30
|
+
restore-keys: ${{ runner.os }}-gems-
|
|
31
|
+
- name: bundle install --gemfile=test/gemfiles/Gemfile.rails-${{matrix.rails}}.x
|
|
32
|
+
run: bundle config path vendor/bundle && bundle install -j$(nproc) --retry 3
|
|
33
|
+
- name: rake test
|
|
34
|
+
run: bundle exec rake test submodules
|
|
35
|
+
env:
|
|
36
|
+
RUBYOPT: "--enable-frozen-string-literal"
|
data/.gitignore
ADDED
data/.gitmodules
ADDED
data/.yardopts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--charset utf-8
|
|
2
2
|
--readme README.md
|
|
3
3
|
--markup markdown
|
|
4
|
-
--markup-provider
|
|
4
|
+
--markup-provider kramdown
|
|
5
5
|
--template-path yard
|
|
6
6
|
--default-return ""
|
|
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/
|
|
11
|
-
--exclude lib/haml/template/plugin.rb
|
|
10
|
+
--exclude lib/haml/plugin.rb
|
|
12
11
|
--exclude lib/haml/railtie.rb
|
|
13
12
|
--exclude lib/haml/helpers/action_view_mods.rb
|
|
14
13
|
--exclude lib/haml/helpers/xss_mods.rb
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,149 @@
|
|
|
1
1
|
# Haml Changelog
|
|
2
2
|
|
|
3
|
+
## 5.2.2
|
|
4
|
+
Released on July 27, 2021
|
|
5
|
+
([diff](https://github.com/haml/haml/compare/v5.2.1...v5.2.2)).
|
|
6
|
+
|
|
7
|
+
* Support for adding Annotations to Haml output (a Rails feature 6.1+)
|
|
8
|
+
* Expanded test matrix to include Ruby 3.0 and Rails 6.1
|
|
9
|
+
* Only testing Ruby 2.7+ and Rails 5.2+
|
|
10
|
+
|
|
11
|
+
## 5.2.1
|
|
12
|
+
|
|
13
|
+
Released on November 30, 2020
|
|
14
|
+
([diff](https://github.com/haml/haml/compare/v5.2.0...v5.2.1)).
|
|
15
|
+
|
|
16
|
+
* Add in improved "multiline" support for attributes [#1043](https://github.com/haml/haml/issues/1043)
|
|
17
|
+
|
|
18
|
+
## 5.2
|
|
19
|
+
|
|
20
|
+
Released on September 28, 2020
|
|
21
|
+
([diff](https://github.com/haml/haml/compare/v5.1.2...v5.2.0)).
|
|
22
|
+
|
|
23
|
+
* Fix crash in the attribute optimizer when `#inspect` is overridden in TrueClass / FalseClass [#972](https://github.com/haml/haml/issues/972)
|
|
24
|
+
* 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))
|
|
25
|
+
* 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)
|
|
26
|
+
|
|
27
|
+
## 5.1.2
|
|
28
|
+
|
|
29
|
+
Released on August 6, 2019
|
|
30
|
+
([diff](https://github.com/haml/haml/compare/v5.1.1...v5.1.2)).
|
|
31
|
+
|
|
32
|
+
* Fix crash in some environments such as New Relic by unfreezing string literals for ParseNode#inspect. [#1016](https://github.com/haml/haml/pull/1016) (thanks [Jalyna](https://github.com/jalyna))
|
|
33
|
+
|
|
34
|
+
## 5.1.1
|
|
35
|
+
|
|
36
|
+
Released on May 25, 2019
|
|
37
|
+
([diff](https://github.com/haml/haml/compare/v5.1.0...v5.1.1)).
|
|
38
|
+
|
|
39
|
+
* Fix NameError bug that happens on ruby 2.6.1-2.6.3 + haml 5.1.0 + rails < 5.1 + erubi. (Akira Matsuda)
|
|
40
|
+
|
|
41
|
+
## 5.1.0
|
|
42
|
+
|
|
43
|
+
Released on May 16, 2019
|
|
44
|
+
([diff](https://github.com/haml/haml/compare/v5.0.4...v5.1.0)).
|
|
45
|
+
|
|
46
|
+
* Rails 6 support [#1008](https://github.com/haml/haml/pull/1008) (thanks [Seb Jacobs](https://github.com/sebjacobs))
|
|
47
|
+
* Add `escape_filter_interpolations` option for backwards compatibility with haml 4 defaults [#984](https://github.com/haml/haml/pull/984) (thanks [Will Jordan](https://github.com/wjordan))
|
|
48
|
+
* Fix error on empty :javascript and :css filter blocks [#986](https://github.com/haml/haml/pull/986) (thanks [Will Jordan](https://github.com/wjordan))
|
|
49
|
+
* Respect changes in Haml::Options.defaults in `Haml::TempleEngine` options (Takashi Kokubun)
|
|
50
|
+
* Un-freeze TempleEngine precompiled string literals [#983](https://github.com/haml/haml/pull/983) (thanks [Will Jordan](https://github.com/wjordan))
|
|
51
|
+
* Various performance/memory improvements [#965](https://github.com/haml/haml/pull/965), [#966](https://github.com/haml/haml/pull/966), [#963](https://github.com/haml/haml/pull/963) (thanks [Dillon Welch](https://github.com/oniofchaos))
|
|
52
|
+
* Enable `frozen_string_literal` magic comment for all .rb files [#967](https://github.com/haml/haml/pull/967) (thanks [Dillon Welch](https://github.com/oniofchaos))
|
|
53
|
+
|
|
54
|
+
## 5.0.4
|
|
55
|
+
|
|
56
|
+
Released on October 13, 2017
|
|
57
|
+
([diff](https://github.com/haml/haml/compare/v5.0.3...v5.0.4)).
|
|
58
|
+
|
|
59
|
+
* Fix `haml -c --stdin` regression in 5.0.2. [#958](https://github.com/haml/haml/pull/958) (thanks [Timo Göllner](https://github.com/TeaMoe))
|
|
60
|
+
* Ruby 2.5 support (it wasn't working due to Ripper API change). (Akira Matsuda)
|
|
61
|
+
|
|
62
|
+
## 5.0.3
|
|
63
|
+
|
|
64
|
+
Released on September 7, 2017
|
|
65
|
+
([diff](https://github.com/haml/haml/compare/v5.0.2...v5.0.3)).
|
|
66
|
+
|
|
67
|
+
* Use `String#dump` instead of `String#inspect` to generate string literal. (Takashi Kokubun)
|
|
68
|
+
* Fix Erubi superclass mismatch error. [#952](https://github.com/haml/haml/pull/952) (thanks [Robin Daugherty](https://github.com/RobinDaugherty))
|
|
69
|
+
|
|
70
|
+
## 5.0.2
|
|
71
|
+
|
|
72
|
+
Released on August 1, 2017
|
|
73
|
+
([diff](https://github.com/haml/haml/compare/v5.0.1...v5.0.2)).
|
|
74
|
+
|
|
75
|
+
* Let `haml -c` fail if generated Ruby code is syntax error. [#880](https://github.com/haml/haml/issues/880) (Takashi Kokubun)
|
|
76
|
+
* Fix `NoMethodError` bug caused with Sprockets 3 and :sass filter. [#930](https://github.com/haml/haml/pull/930) (thanks [Gonzalez Maximiliano](https://github.com/emaxi))
|
|
77
|
+
* Fix `list_of` helper with multi-line content. [#933](https://github.com/haml/haml/pull/933) (thanks [Benoit Larroque](https://github.com/zetaben))
|
|
78
|
+
* Optimize rendering performance by changing timing to fix textareas. [#941](https://github.com/haml/haml/pull/941) (Takashi Kokubun)
|
|
79
|
+
* Fix `TypeError` with empty :ruby filter. [#942](https://github.com/haml/haml/pull/942) (Takashi Kokubun)
|
|
80
|
+
* Fix inconsistent attribute sort order. (Takashi Kokubun)
|
|
81
|
+
|
|
82
|
+
## 5.0.1
|
|
83
|
+
|
|
84
|
+
Released on May 3, 2017
|
|
85
|
+
([diff](https://github.com/haml/haml/compare/v5.0.0...v5.0.1)).
|
|
86
|
+
|
|
87
|
+
* Fix parsing attributes including string interpolation. [#917](https://github.com/haml/haml/pull/917) [#921](https://github.com/haml/haml/issues/921)
|
|
88
|
+
* Stop distributing test files in gem package and allow installing on Windows.
|
|
89
|
+
* Use ActionView's Erubi/Erubis handler for erb filter only on ActionView. [#914](https://github.com/haml/haml/pull/914)
|
|
90
|
+
|
|
91
|
+
## 5.0.0
|
|
92
|
+
|
|
93
|
+
Released on April 26, 2017
|
|
94
|
+
([diff](https://github.com/haml/haml/compare/4.0.7...v5.0.0)).
|
|
95
|
+
|
|
96
|
+
Breaking Changes
|
|
97
|
+
|
|
98
|
+
* Haml now requires Ruby 2.0.0 or above.
|
|
99
|
+
* Rails 3 is no longer supported, matching the official
|
|
100
|
+
[Maintenance Policy for Ruby on Rails](http://weblog.rubyonrails.org/2013/2/24/maintenance-policy-for-ruby-on-rails/).
|
|
101
|
+
Use Haml 4 if you want to use Rails 3.
|
|
102
|
+
(Tee Parham)
|
|
103
|
+
* Remove `:ugly` option ([#894](https://github.com/haml/haml/pull/894))
|
|
104
|
+
* The `haml` command's debug option (`-d`) no longer executes the Haml code, but
|
|
105
|
+
rather checks the generated Ruby syntax for errors.
|
|
106
|
+
* Drop parser/compiler accessor from `Haml::Engine`. Modify `Haml::Engine#initialize` options
|
|
107
|
+
or `Haml::Template.options` instead. (Takashi Kokubun)
|
|
108
|
+
* Drop dynamic quotes support and always escape `'` for `escape_html`/`escape_attrs` instead.
|
|
109
|
+
Also, escaped results are slightly changed and always unified to the same characters. (Takashi Kokubun)
|
|
110
|
+
* Don't preserve newlines in attributes. (Takashi Kokubun)
|
|
111
|
+
* HTML escape interpolated code in filters.
|
|
112
|
+
[#770](https://github.com/haml/haml/pull/770)
|
|
113
|
+
(Matt Wildig)
|
|
114
|
+
|
|
115
|
+
:javascript
|
|
116
|
+
#{JSON.generate(foo: "bar")}
|
|
117
|
+
Haml 4 output: {"foo":"bar"}
|
|
118
|
+
Haml 5 output: {"foo":"bar"}
|
|
119
|
+
|
|
120
|
+
Added
|
|
121
|
+
|
|
122
|
+
* Add a tracing option. When enabled, Haml will output a data-trace attribute on each tag showing the path
|
|
123
|
+
to the source Haml file from which it was generated. Thanks [Alex Babkin](https://github.com/ababkin).
|
|
124
|
+
* Add `haml_tag_if` to render a block, conditionally wrapped in another element (Matt Wildig)
|
|
125
|
+
* Support Rails 5.1 Erubi template handler.
|
|
126
|
+
* Support Sprockets 3. Thanks [Sam Davies](https://github.com/samphilipd) and [Jeremy Venezia](https://github.com/jvenezia).
|
|
127
|
+
* General performance and memory usage improvements. (Akira Matsuda)
|
|
128
|
+
* Analyze attribute values by Ripper and render static attributes beforehand. (Takashi Kokubun)
|
|
129
|
+
* Optimize attribute rendering about 3x faster. (Takashi Kokubun)
|
|
130
|
+
* Add temple gem as dependency and create `Haml::TempleEngine` class.
|
|
131
|
+
Some methods in `Haml::Compiler` are migrated to `Haml::TempleEngine`. (Takashi Kokubun)
|
|
132
|
+
|
|
133
|
+
Fixed
|
|
134
|
+
|
|
135
|
+
* Fix for attribute merging. When an attribute method (or literal nested hash)
|
|
136
|
+
was used in an old style attribute hash and there is also a (non-static) new
|
|
137
|
+
style hash there is an error. The fix can result in different behavior in
|
|
138
|
+
some circumstances. See the [commit message](https://github.com/haml/haml/tree/e475b015d3171fb4c4f140db304f7970c787d6e3)
|
|
139
|
+
for detailed info. (Matt Wildig)
|
|
140
|
+
* Make escape_once respect hexadecimal references. (Matt Wildig)
|
|
141
|
+
* Don't treat the 'data' attribute specially when merging attribute hashes. (Matt Wildig and Norman Clarke)
|
|
142
|
+
* Fix #@foo and #$foo style interpolation that was not working in html_safe mode. (Akira Matsuda)
|
|
143
|
+
* Allow `@` as tag's class name. Thanks [Joe Bartlett](https://github.com/redoPop).
|
|
144
|
+
* Raise `Haml::InvalidAttributeNameError` when attribute name includes invalid characters. (Takashi Kokubun)
|
|
145
|
+
* Don't ignore unexpected exceptions on initializing `ActionView::OutputBuffer`. (Takashi Kokubun)
|
|
146
|
+
|
|
3
147
|
## 4.0.7
|
|
4
148
|
|
|
5
149
|
Released on August 10, 2015
|
|
@@ -11,7 +155,6 @@ Released on August 10, 2015
|
|
|
11
155
|
|
|
12
156
|
Released on Dec 1, 2014 ([diff](https://github.com/haml/haml/compare/4.0.5...4.0.6)).
|
|
13
157
|
|
|
14
|
-
|
|
15
158
|
* Fix warning on Ruby 1.8.7 "regexp has invalid interval" (thanks [Elia Schito](https://github.com/elia)).
|
|
16
159
|
|
|
17
160
|
## 4.0.5
|
|
@@ -76,7 +219,7 @@ Released March 21, 2013 ([diff](https://github.com/haml/haml/compare/4.0.0...4.0
|
|
|
76
219
|
|
|
77
220
|
## 4.0.0
|
|
78
221
|
|
|
79
|
-
* The Haml
|
|
222
|
+
* The Haml executable now accepts an `--autoclose` option. You can now
|
|
80
223
|
specify a list of tags that should be autoclosed
|
|
81
224
|
|
|
82
225
|
* The `:ruby` filter no longer redirects $stdout to the Haml document, as this
|
|
@@ -113,7 +256,7 @@ Released March 21, 2013 ([diff](https://github.com/haml/haml/compare/4.0.0...4.0
|
|
|
113
256
|
|
|
114
257
|
* All Hash attribute values are now treated as HTML5 data, regardless of key.
|
|
115
258
|
Previously only the "data" key was treated this way. Allowing arbitrary keys
|
|
116
|
-
means you can now easily use this
|
|
259
|
+
means you can now easily use this feature for Aria attributes, among other
|
|
117
260
|
uses.
|
|
118
261
|
(thanks to [Elvin Efendi](https://github.com/ElvinEfendi))
|
|
119
262
|
|
|
@@ -532,7 +675,6 @@ The {file:HAML_REFERENCE.md#ugly-option `:ugly` option} is now on by default
|
|
|
532
675
|
in the testing environment in Rails to help tests run faster.
|
|
533
676
|
|
|
534
677
|
## 3.0.0
|
|
535
|
-
{#3-0-0}
|
|
536
678
|
|
|
537
679
|
[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.0).
|
|
538
680
|
|
data/FAQ.md
CHANGED
|
@@ -2,14 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Haml
|
|
4
4
|
|
|
5
|
-
###
|
|
6
|
-
{#q-indentation-in-production}
|
|
7
|
-
|
|
8
|
-
To improve performance, Haml defaults to {Haml::Options#ugly "ugly" mode} in
|
|
9
|
-
Rails apps running in production.
|
|
10
|
-
|
|
11
|
-
### How do I put a punctuation mark after an element, like "`I like <strong>cake</strong>!`"?
|
|
12
|
-
{#q-punctuation}
|
|
5
|
+
### How do I put a punctuation mark after an element, like "`I like <strong>cake</strong>!`"? {#q-punctuation}
|
|
13
6
|
|
|
14
7
|
Expressing the structure of a document
|
|
15
8
|
and expressing inline formatting are two very different problems.
|
|
@@ -37,8 +30,7 @@ then it's even easier:
|
|
|
37
30
|
|
|
38
31
|
%p== I like #{link_to 'chocolate', 'http://franschocolates.com'}!
|
|
39
32
|
|
|
40
|
-
### How do I stop Haml from indenting the contents of my `pre` and `textarea` tags?
|
|
41
|
-
{#q-preserve}
|
|
33
|
+
### How do I stop Haml from indenting the contents of my `pre` and `textarea` tags? {#q-preserve}
|
|
42
34
|
|
|
43
35
|
Because Haml automatically indents the HTML source code,
|
|
44
36
|
the contents of whitespace-sensitive tags like `pre` and `textarea`
|
|
@@ -78,8 +70,7 @@ and renders
|
|
|
78
70
|
|
|
79
71
|
<p><textarea>Foo
Bar</textarea></p>
|
|
80
72
|
|
|
81
|
-
### How do I make my long lines of Ruby code look nicer in my Haml document?
|
|
82
|
-
{#q-multiline}
|
|
73
|
+
### How do I make my long lines of Ruby code look nicer in my Haml document? {#q-multiline}
|
|
83
74
|
|
|
84
75
|
Put them in a helper or your model.
|
|
85
76
|
|
|
@@ -125,8 +116,7 @@ in Haml, you have to do
|
|
|
125
116
|
- form_for stuff do
|
|
126
117
|
...
|
|
127
118
|
|
|
128
|
-
### I have Haml installed. Why is Rails (only looking for `.html.erb` files | rendering Haml files as plain text | rendering Haml files as blank pages)?
|
|
129
|
-
{#q-blank-page}
|
|
119
|
+
### I have Haml installed. Why is Rails (only looking for `.html.erb` files | rendering Haml files as plain text | rendering Haml files as blank pages)? {#q-blank-page}
|
|
130
120
|
|
|
131
121
|
There are several reasons these things might be happening.
|
|
132
122
|
First of all, make sure that Haml really is installed;
|
data/Gemfile
ADDED
data/MIT-LICENSE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright (c) 2006-
|
|
1
|
+
Copyright (c) 2006-2019 Hampton Catlin and Natalie Weizenbaum
|
|
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
|
|
@@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
17
17
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
18
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
19
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
|
@@ -1,34 +1,53 @@
|
|
|
1
1
|
# Haml
|
|
2
2
|
|
|
3
|
-
[](http://rubygems.org/gems/haml)
|
|
4
|
+
[](http://travis-ci.org/haml/haml)
|
|
5
|
+
[](https://codeclimate.com/github/haml/haml)
|
|
6
|
+
[](http://inch-ci.org/github/haml/haml)
|
|
4
7
|
|
|
5
8
|
Haml is a templating engine for HTML. It's designed to make it both easier and
|
|
6
9
|
more pleasant to write HTML documents, by eliminating redundancy, reflecting the
|
|
7
10
|
underlying structure that the document represents, and providing an elegant syntax
|
|
8
11
|
that's both powerful and easy to understand.
|
|
9
12
|
|
|
13
|
+
### Supported Versions
|
|
14
|
+
|
|
15
|
+
* Ruby 2.6+
|
|
16
|
+
* Rails 5.1+
|
|
17
|
+
|
|
18
|
+
Other versions may likely work, but we don't test against them.
|
|
19
|
+
|
|
10
20
|
## Basic Usage
|
|
11
21
|
|
|
12
22
|
Haml can be used from the command line or as part of a Ruby web framework. The
|
|
13
23
|
first step is to install the gem:
|
|
14
24
|
|
|
15
|
-
|
|
25
|
+
~~~sh
|
|
26
|
+
gem install haml
|
|
27
|
+
~~~
|
|
16
28
|
|
|
17
29
|
After you write some Haml, you can run
|
|
18
30
|
|
|
19
|
-
|
|
31
|
+
~~~sh
|
|
32
|
+
haml document.haml
|
|
33
|
+
~~~
|
|
20
34
|
|
|
21
35
|
to compile it to HTML. For more information on these commands, check out
|
|
22
36
|
|
|
23
|
-
|
|
37
|
+
~~~sh
|
|
38
|
+
haml --help
|
|
39
|
+
~~~
|
|
24
40
|
|
|
25
|
-
To use Haml
|
|
26
|
-
documentation](http://haml.info/docs/yardoc/).
|
|
41
|
+
To use Haml programmatically, check out the [YARD documentation](http://haml.info/docs/yardoc/).
|
|
27
42
|
|
|
28
43
|
## Using Haml with Rails
|
|
29
44
|
|
|
30
45
|
To use Haml with Rails, simply add Haml to your Gemfile and run `bundle`.
|
|
31
46
|
|
|
47
|
+
~~~ruby
|
|
48
|
+
gem 'haml'
|
|
49
|
+
~~~
|
|
50
|
+
|
|
32
51
|
If you'd like to replace Rails's Erb-based generators with Haml, add
|
|
33
52
|
[haml-rails](https://github.com/indirect/haml-rails) to your Gemfile as well.
|
|
34
53
|
|
|
@@ -36,58 +55,76 @@ If you'd like to replace Rails's Erb-based generators with Haml, add
|
|
|
36
55
|
|
|
37
56
|
The most basic element of Haml is a shorthand for creating HTML:
|
|
38
57
|
|
|
39
|
-
|
|
58
|
+
~~~haml
|
|
59
|
+
%tagname{:attr1 => 'value1', :attr2 => 'value2'} Contents
|
|
60
|
+
~~~
|
|
40
61
|
|
|
41
62
|
No end-tag is needed; Haml handles that automatically. If you prefer HTML-style
|
|
42
63
|
attributes, you can also use:
|
|
43
64
|
|
|
44
|
-
|
|
65
|
+
~~~haml
|
|
66
|
+
%tagname(attr1='value1' attr2='value2') Contents
|
|
67
|
+
~~~
|
|
45
68
|
|
|
46
69
|
Adding `class` and `id` attributes is even easier. Haml uses the same syntax as
|
|
47
70
|
the CSS that styles the document:
|
|
48
71
|
|
|
49
|
-
|
|
72
|
+
~~~haml
|
|
73
|
+
%tagname#id.class
|
|
74
|
+
~~~
|
|
50
75
|
|
|
51
76
|
In fact, when you're using the `<div>` tag, it becomes _even easier_. Because
|
|
52
77
|
`<div>` is such a common element, a tag without a name defaults to a div. So
|
|
53
78
|
|
|
54
|
-
|
|
79
|
+
~~~haml
|
|
80
|
+
#foo Hello!
|
|
81
|
+
~~~
|
|
55
82
|
|
|
56
83
|
becomes
|
|
57
84
|
|
|
58
|
-
|
|
85
|
+
~~~html
|
|
86
|
+
<div id='foo'>Hello!</div>
|
|
87
|
+
~~~
|
|
59
88
|
|
|
60
89
|
Haml uses indentation to bring the individual elements to represent the HTML
|
|
61
90
|
structure. A tag's children are indented beneath than the parent tag. Again, a
|
|
62
91
|
closing tag is automatically added. For example:
|
|
63
92
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
93
|
+
~~~haml
|
|
94
|
+
%ul
|
|
95
|
+
%li Salt
|
|
96
|
+
%li Pepper
|
|
97
|
+
~~~
|
|
67
98
|
|
|
68
99
|
becomes:
|
|
69
100
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
101
|
+
~~~html
|
|
102
|
+
<ul>
|
|
103
|
+
<li>Salt</li>
|
|
104
|
+
<li>Pepper</li>
|
|
105
|
+
</ul>
|
|
106
|
+
~~~
|
|
74
107
|
|
|
75
108
|
You can also put plain text as a child of an element:
|
|
76
109
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
110
|
+
~~~haml
|
|
111
|
+
%p
|
|
112
|
+
Hello,
|
|
113
|
+
World!
|
|
114
|
+
~~~
|
|
80
115
|
|
|
81
116
|
It's also possible to embed Ruby code into Haml documents. An equals sign, `=`,
|
|
82
117
|
will output the result of the code. A hyphen, `-`, will run the code but not
|
|
83
118
|
output the result. You can even use control statements like `if` and `while`:
|
|
84
119
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
120
|
+
~~~haml
|
|
121
|
+
%p
|
|
122
|
+
Date/Time:
|
|
123
|
+
- now = DateTime.now
|
|
124
|
+
%strong= now
|
|
125
|
+
- if now > DateTime.parse("December 31, 2006")
|
|
126
|
+
= "Happy new " + "year!"
|
|
127
|
+
~~~
|
|
91
128
|
|
|
92
129
|
Haml provides far more tools than those presented here. Check out the [reference
|
|
93
130
|
documentation](http://haml.info/docs/yardoc/file.REFERENCE.html)
|
|
@@ -105,18 +142,22 @@ Contributions are welcomed, but before you get started please read the
|
|
|
105
142
|
[guidelines](http://haml.info/development.html#contributing).
|
|
106
143
|
|
|
107
144
|
After forking and then cloning the repo locally, install Bundler and then use it
|
|
108
|
-
to install the development gem
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
145
|
+
to install the development gem dependencies:
|
|
146
|
+
~~~sh
|
|
147
|
+
gem install bundler
|
|
148
|
+
bundle install
|
|
149
|
+
~~~
|
|
112
150
|
|
|
113
151
|
Once this is complete, you should be able to run the test suite:
|
|
114
|
-
|
|
115
|
-
|
|
152
|
+
~~~sh
|
|
153
|
+
rake
|
|
154
|
+
~~~
|
|
116
155
|
|
|
117
156
|
You'll get a warning that you need to install haml-spec, so run this:
|
|
118
157
|
|
|
119
|
-
|
|
158
|
+
~~~sh
|
|
159
|
+
git submodule update --init
|
|
160
|
+
~~~
|
|
120
161
|
|
|
121
162
|
At this point `rake` should run without error or warning and you are ready to
|
|
122
163
|
start working on your patch!
|
|
@@ -124,36 +165,38 @@ start working on your patch!
|
|
|
124
165
|
Note that you can also run just one test out of the test suite if you're working
|
|
125
166
|
on a specific area:
|
|
126
167
|
|
|
127
|
-
|
|
168
|
+
~~~sh
|
|
169
|
+
ruby -Itest test/helper_test.rb -n test_buffer_access
|
|
170
|
+
~~~
|
|
128
171
|
|
|
129
|
-
Haml supports Ruby
|
|
130
|
-
both 1.9 and 1.8.
|
|
172
|
+
Haml currently supports Ruby 2.7.0 and higher, so please make sure your changes run on 2.7+.
|
|
131
173
|
|
|
132
174
|
## Team
|
|
133
175
|
|
|
134
176
|
### Current Maintainers
|
|
135
177
|
|
|
136
|
-
* [
|
|
137
|
-
* [
|
|
178
|
+
* [Hampton Catlin](https://github.com/hcatlin)
|
|
179
|
+
* [Takashi Kokubun](https://github.com/k0kubun)
|
|
138
180
|
* [Akira Matsuda](https://github.com/amatsuda)
|
|
139
181
|
|
|
140
182
|
### Alumni
|
|
141
183
|
|
|
142
184
|
Haml was created by [Hampton Catlin](http://hamptoncatlin.com), the author of
|
|
143
|
-
the original implementation.
|
|
144
|
-
but still consults on language issues.
|
|
185
|
+
the original implementation.
|
|
145
186
|
|
|
146
|
-
[
|
|
187
|
+
[Natalie Weizenbaum](https://github.com/nex3) was for many years the primary developer
|
|
147
188
|
and architect of the "modern" Ruby implementation of Haml.
|
|
148
189
|
|
|
190
|
+
This project's been around for many years, and we have many amazing people who kept the project
|
|
191
|
+
alive! as former maintainers like:
|
|
149
192
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
193
|
+
[Norman Clarke](http://github.com/norman)
|
|
194
|
+
[Matt Wildig](https://github.com/mattwildig)
|
|
195
|
+
[Tee Parham](https://github.com/teeparham)
|
|
153
196
|
|
|
154
|
-
|
|
197
|
+
## License
|
|
155
198
|
|
|
156
|
-
Copyright (c) 2006-
|
|
199
|
+
Copyright (c) 2006-2021 Hampton Catlin, Natalie Weizenbaum and the Haml team
|
|
157
200
|
|
|
158
201
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
159
202
|
this software and associated documentation files (the "Software"), to deal in
|