haml 4.0.0 → 5.0.0
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 +7 -0
- data/.yardopts +1 -1
- data/CHANGELOG.md +117 -5
- data/FAQ.md +7 -17
- data/MIT-LICENSE +1 -1
- data/README.md +85 -42
- data/REFERENCE.md +181 -86
- data/Rakefile +47 -51
- data/lib/haml/attribute_builder.rb +163 -0
- data/lib/haml/attribute_compiler.rb +215 -0
- data/lib/haml/attribute_parser.rb +144 -0
- data/lib/haml/buffer.rb +38 -128
- data/lib/haml/compiler.rb +88 -295
- data/lib/haml/engine.rb +25 -41
- data/lib/haml/error.rb +3 -0
- data/lib/haml/escapable.rb +49 -0
- data/lib/haml/exec.rb +33 -19
- data/lib/haml/filters.rb +20 -24
- data/lib/haml/generator.rb +41 -0
- data/lib/haml/helpers/action_view_extensions.rb +3 -2
- data/lib/haml/helpers/action_view_mods.rb +44 -66
- data/lib/haml/helpers/action_view_xss_mods.rb +1 -0
- data/lib/haml/helpers/safe_erubi_template.rb +27 -0
- data/lib/haml/helpers/safe_erubis_template.rb +16 -4
- data/lib/haml/helpers/xss_mods.rb +18 -12
- data/lib/haml/helpers.rb +122 -58
- data/lib/haml/options.rb +39 -46
- data/lib/haml/parser.rb +278 -217
- data/lib/haml/{template/plugin.rb → plugin.rb} +8 -15
- data/lib/haml/railtie.rb +21 -11
- data/lib/haml/sass_rails_filter.rb +17 -4
- data/lib/haml/template/options.rb +12 -2
- data/lib/haml/template.rb +12 -6
- data/lib/haml/temple_engine.rb +120 -0
- data/lib/haml/temple_line_counter.rb +29 -0
- data/lib/haml/util.rb +80 -199
- data/lib/haml/version.rb +2 -1
- data/lib/haml.rb +2 -1
- data/test/attribute_parser_test.rb +101 -0
- data/test/engine_test.rb +306 -176
- data/test/filters_test.rb +32 -19
- data/test/gemfiles/Gemfile.rails-4.0.x +11 -0
- data/test/gemfiles/Gemfile.rails-4.0.x.lock +87 -0
- data/test/gemfiles/Gemfile.rails-4.1.x +5 -0
- data/test/gemfiles/Gemfile.rails-4.2.x +5 -0
- data/test/gemfiles/Gemfile.rails-5.0.x +4 -0
- data/test/helper_test.rb +282 -96
- data/test/options_test.rb +22 -0
- data/test/parser_test.rb +71 -4
- data/test/results/bemit.xhtml +4 -0
- data/test/results/eval_suppressed.xhtml +4 -4
- data/test/results/helpers.xhtml +43 -41
- data/test/results/helpful.xhtml +6 -3
- data/test/results/just_stuff.xhtml +21 -20
- data/test/results/list.xhtml +9 -9
- data/test/results/nuke_inner_whitespace.xhtml +22 -22
- data/test/results/nuke_outer_whitespace.xhtml +84 -92
- data/test/results/original_engine.xhtml +17 -17
- data/test/results/partial_layout.xhtml +4 -3
- data/test/results/partial_layout_erb.xhtml +4 -3
- data/test/results/partials.xhtml +11 -10
- data/test/results/silent_script.xhtml +63 -63
- data/test/results/standard.xhtml +156 -159
- data/test/results/tag_parsing.xhtml +19 -19
- data/test/results/very_basic.xhtml +2 -2
- data/test/results/whitespace_handling.xhtml +56 -50
- data/test/template_test.rb +44 -53
- data/test/template_test_helper.rb +38 -0
- data/test/templates/_text_area_helper.html.haml +4 -0
- data/test/templates/bemit.haml +3 -0
- data/test/templates/just_stuff.haml +1 -0
- data/test/templates/partial_layout_erb.erb +1 -1
- data/test/templates/standard_ugly.haml +1 -0
- data/test/templates/with_bom.haml +1 -0
- data/test/temple_line_counter_test.rb +40 -0
- data/test/test_helper.rb +26 -12
- data/test/util_test.rb +6 -47
- metadata +88 -106
- data/lib/haml/helpers/rails_323_textarea_fix.rb +0 -24
- 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-master +0 -4
- data/test/templates/_av_partial_1_ugly.haml +0 -9
- data/test/templates/_av_partial_2_ugly.haml +0 -5
- data/test/templates/action_view_ugly.haml +0 -47
- data/test/templates/standard_ugly.haml +0 -43
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7fa1e64aca629e46493a148b6159feb77763ba0d
|
4
|
+
data.tar.gz: 912f3565b782829c0651604333a0d5fd823c45a1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d8e860a0fc047d158a7a1d08f349a5555ae9a0afd578327c16cca624c3c0425a323e40cc3185f8ba8fede3ed79d24babb44f634969a69707a46f27d92b925b15
|
7
|
+
data.tar.gz: f3e66b26cf401ac0081721f44322a4fe39c0b0c486d6b4b0dd7e665e483be86f6f1769a0c94ed00b2646e3d76fb7be0ebe2e40c75943c0a5774e38cb3f17a4e2
|
data/.yardopts
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,120 @@
|
|
1
1
|
# Haml Changelog
|
2
2
|
|
3
|
+
## 5.0.0
|
4
|
+
|
5
|
+
Released on April 26, 2017
|
6
|
+
([diff](https://github.com/haml/haml/compare/4.0.7...5.0.0)).
|
7
|
+
|
8
|
+
* Haml now requires Ruby 2.0.0 or above.
|
9
|
+
* Rails 3 is no longer supported, matching the official
|
10
|
+
[Maintenance Policy for Ruby on Rails](http://weblog.rubyonrails.org/2013/2/24/maintenance-policy-for-ruby-on-rails/).
|
11
|
+
(Tee Parham)
|
12
|
+
* Fix for attribute merging. When an attribute method (or literal nested hash)
|
13
|
+
was used in an old style attribute hash and there is also a (non-static) new
|
14
|
+
style hash there is an error. The fix can result in different behavior in
|
15
|
+
some circumstances. See the [commit message](https://github.com/haml/haml/tree/e475b015d3171fb4c4f140db304f7970c787d6e3)
|
16
|
+
for detailed info. (Matt Wildig)
|
17
|
+
* Make escape_once respect hexadecimal references. (Matt Wildig)
|
18
|
+
* General performance and memory usage improvements. (Akira Matsuda)
|
19
|
+
* Don't treat the 'data' attribute specially when merging attribute hashes. (Matt Wildig and Norman Clarke)
|
20
|
+
* Add a tracing option. When enabled, Haml will output a data-trace attribute on each tag showing the path
|
21
|
+
to the source Haml file from which it was generated. Thanks [Alex Babkin](https://github.com/ababkin).
|
22
|
+
* Fix #@foo and #$foo style interpolation that was not working in html_safe mode. (Akira Matsuda)
|
23
|
+
* Add `haml_tag_if` to render a block, conditionally wrapped in another element (Matt Wildig)
|
24
|
+
* Escape Ruby script interpolated in filters. (Matt Wildig)
|
25
|
+
* The `haml` command's debug option (`-d`) no longer executes the Haml code, but
|
26
|
+
rather checks the generated Ruby syntax for errors.
|
27
|
+
* Support Rails 5.1 Erubi template handler.
|
28
|
+
* Support Sprockets 3. Thanks [Sam Davies](https://github.com/samphilipd) and [Jeremy Venezia](https://github.com/jvenezia).
|
29
|
+
* Allow `@` as tag's class name. Thanks [Joe Bartlett](https://github.com/redoPop).
|
30
|
+
* Raise `Haml::InvalidAttributeNameError` when attribute name includes invalid characters. (Takashi Kokubun)
|
31
|
+
* Drop dynamic quotes support and always escape `'` for `escape_html`/`escape_attrs` instead.
|
32
|
+
Also, escaped results are slightly changed and always unified to the same characters. (Takashi Kokubun)
|
33
|
+
* Don't preserve newlines in attributes. (Takashi Kokubun)
|
34
|
+
* Add temple gem as dependency and create `Haml::TempleEngine` class.
|
35
|
+
Some methods in `Haml::Compiler` are migrated to `Haml::TempleEngine`. (Takashi Kokubun)
|
36
|
+
* Drop parser/compiler accessor from `Haml::Engine`. Modify `Haml::Engine#initialize` options
|
37
|
+
or `Haml::Template.options` instead. (Takashi Kokubun)
|
38
|
+
* Don't ignore unexpected exceptions on initializing `ActionView::OutputBuffer`. (Takashi Kokubun)
|
39
|
+
* Analyze attribute values by Ripper and render static attributes beforehand. (Takashi Kokubun)
|
40
|
+
* Optimize attribute rendering about 3x faster. (Takashi Kokubun)
|
41
|
+
|
42
|
+
## 4.0.7
|
43
|
+
|
44
|
+
Released on August 10, 2015
|
45
|
+
([diff](https://github.com/haml/haml/compare/4.0.6...4.0.7)).
|
46
|
+
|
47
|
+
* Significantly improve performance of regexp used to fix whitespace handling in textareas (thanks [Stan Hu](https://github.com/stanhu)).
|
48
|
+
|
49
|
+
## 4.0.6
|
50
|
+
|
51
|
+
Released on Dec 1, 2014 ([diff](https://github.com/haml/haml/compare/4.0.5...4.0.6)).
|
52
|
+
|
53
|
+
* Fix warning on Ruby 1.8.7 "regexp has invalid interval" (thanks [Elia Schito](https://github.com/elia)).
|
54
|
+
|
55
|
+
## 4.0.5
|
56
|
+
|
57
|
+
Released on Jan 7, 2014 ([diff](https://github.com/haml/haml/compare/4.0.4...4.0.5)).
|
58
|
+
|
59
|
+
* Fix haml_concat appending unescaped HTML after a call to haml_tag.
|
60
|
+
* Fix for bug whereby when HAML :ugly option is "true",
|
61
|
+
ActionView::Helpers::CaptureHelper::capture returns the whole view buffer
|
62
|
+
when passed a block that returns nothing (thanks [Mircea
|
63
|
+
Moise](https://github.com/mmircea16)).
|
64
|
+
|
65
|
+
## 4.0.4
|
66
|
+
|
67
|
+
Released on November 5, 2013 ([diff](https://github.com/haml/haml/compare/4.0.3...4.0.4)).
|
68
|
+
|
69
|
+
* Check for Rails::Railtie rather than Rails (thanks [Konstantin Shabanov](https://github.com/etehtsea)).
|
70
|
+
* Parser fix to allow literal '#' with suppress_eval (Matt Wildig).
|
71
|
+
* Helpers#escape_once works on frozen strings (as does
|
72
|
+
ERB::Util.html_escape_once for which it acts as a replacement in
|
73
|
+
Rails (thanks [Patrik Metzmacher](https://github.com/patrik)).
|
74
|
+
* Minor test fix (thanks [Mircea Moise](https://github.com/mmircea16)).
|
75
|
+
|
76
|
+
## 4.0.3
|
77
|
+
|
78
|
+
Released May 21, 2013 ([diff](https://github.com/haml/haml/compare/4.0.2...4.0.3)).
|
79
|
+
|
80
|
+
* Compatibility with newer versions of Rails's Erubis handler.
|
81
|
+
* Fix Erubis handler for compatibility with Tilt 1.4.x, too.
|
82
|
+
* Small performance optimization for html_escape.
|
83
|
+
(thanks [Lachlan Sylvester](https://github.com/lsylvester))
|
84
|
+
* Documentation fixes.
|
85
|
+
* Documented some helper methods that were left out of the reference.
|
86
|
+
(thanks [Shane Riley](https://github.com/shaneriley))
|
87
|
+
|
88
|
+
## 4.0.2
|
89
|
+
|
90
|
+
Released April 5, 2013 ([diff](https://github.com/haml/haml/compare/4.0.1...4.0.2)).
|
91
|
+
|
92
|
+
* Explicitly require Erubis to work around bug in older versions of Tilt.
|
93
|
+
* Fix :erb filter printing duplicate content in Rails views.
|
94
|
+
(thanks [Jori Hardman](https://github.com/jorihardman))
|
95
|
+
* Replace range with slice to reduce objects created by `capture_haml`.
|
96
|
+
(thanks [Tieg Zaharia](https://github.com/tiegz))
|
97
|
+
* Correct/improve some documentation.
|
98
|
+
|
99
|
+
## 4.0.1
|
100
|
+
|
101
|
+
Released March 21, 2013 ([diff](https://github.com/haml/haml/compare/4.0.0...4.0.1)).
|
102
|
+
|
103
|
+
* Remove Rails 3.2.3+ textarea hack in favor of a more general solution.
|
104
|
+
* Fix some performance regressions.
|
105
|
+
* Fix support for Rails 4 `text_area` helper method.
|
106
|
+
* Fix data attribute flattening with singleton objects.
|
107
|
+
(thanks [Alisdair McDiarmid](https://github.com/alisdair))
|
108
|
+
* Fix support for sass-rails 4.0 beta.
|
109
|
+
(thanks [Ryunosuke SATO](https://github.com/tricknotes))
|
110
|
+
* Load "haml/template" in Railtie in order to prevent user options set in a
|
111
|
+
Rails initializer from being overwritten
|
112
|
+
* Don't depend on Rails in haml/template to allow using Haml with ActionView
|
113
|
+
but without Rails itself. (thanks [Hunter Haydel](https://github.com/wedgex))
|
114
|
+
|
3
115
|
## 4.0.0
|
4
116
|
|
5
|
-
* The Haml
|
117
|
+
* The Haml executable now accepts an `--autoclose` option. You can now
|
6
118
|
specify a list of tags that should be autoclosed
|
7
119
|
|
8
120
|
* The `:ruby` filter no longer redirects $stdout to the Haml document, as this
|
@@ -12,7 +124,7 @@
|
|
12
124
|
* HTML5 is now the default output format rather than XHTML. This was already
|
13
125
|
the default on Rails 3+, so many users will notice no difference.
|
14
126
|
|
15
|
-
* The :sass filter now wraps its output in a
|
127
|
+
* The :sass filter now wraps its output in a style tag, as do the new :less and
|
16
128
|
:scss filters. The :coffee filter wraps its output in a script tag.
|
17
129
|
|
18
130
|
* Haml now supports only Rails 3 and above, and Ruby 1.8.7 and above. If you
|
@@ -39,7 +151,7 @@
|
|
39
151
|
|
40
152
|
* All Hash attribute values are now treated as HTML5 data, regardless of key.
|
41
153
|
Previously only the "data" key was treated this way. Allowing arbitrary keys
|
42
|
-
means you can now easily use this
|
154
|
+
means you can now easily use this feature for Aria attributes, among other
|
43
155
|
uses.
|
44
156
|
(thanks to [Elvin Efendi](https://github.com/ElvinEfendi))
|
45
157
|
|
@@ -57,7 +169,7 @@
|
|
57
169
|
(thanks to [Péter Pál Koszta](https://github.com/koszta))
|
58
170
|
|
59
171
|
* Filters that rely on third-party template engines are now implemented using
|
60
|
-
[Tilt](github.com/rtomayko/tilt). Several new filters have been added, namely
|
172
|
+
[Tilt](http://github.com/rtomayko/tilt). Several new filters have been added, namely
|
61
173
|
SCSS (:scss), LessCSS, (:less), and Coffeescript (:coffee/:coffeescript).
|
62
174
|
|
63
175
|
Though the list of "official" filters is kept intentionally small, Haml comes
|
@@ -458,7 +570,6 @@ The {file:HAML_REFERENCE.md#ugly-option `:ugly` option} is now on by default
|
|
458
570
|
in the testing environment in Rails to help tests run faster.
|
459
571
|
|
460
572
|
## 3.0.0
|
461
|
-
{#3-0-0}
|
462
573
|
|
463
574
|
[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.0).
|
464
575
|
|
@@ -1287,3 +1398,4 @@ has been moved to [YARD](http://yard.soen.ca).
|
|
1287
1398
|
YARD is an excellent documentation system,
|
1288
1399
|
and allows us to write our documentation in [Maruku](http://maruku.rubyforge.org),
|
1289
1400
|
which is also excellent.
|
1401
|
+
>>>>>>> External Changes
|
data/FAQ.md
CHANGED
@@ -2,15 +2,7 @@
|
|
2
2
|
|
3
3
|
## Haml
|
4
4
|
|
5
|
-
###
|
6
|
-
{#q-indentation-in-production}
|
7
|
-
|
8
|
-
To improve performance, Haml defaults to {file:HAML_REFERENCE.md#ugly-option "ugly" mode} in Rails
|
9
|
-
apps running in production.
|
10
|
-
|
11
|
-
|
12
|
-
### How do I put a punctuation mark after an element, like "`I like <strong>cake</strong>!`"?
|
13
|
-
{#q-punctuation}
|
5
|
+
### How do I put a punctuation mark after an element, like "`I like <strong>cake</strong>!`"? {#q-punctuation}
|
14
6
|
|
15
7
|
Expressing the structure of a document
|
16
8
|
and expressing inline formatting are two very different problems.
|
@@ -38,8 +30,7 @@ then it's even easier:
|
|
38
30
|
|
39
31
|
%p== I like #{link_to 'chocolate', 'http://franschocolates.com'}!
|
40
32
|
|
41
|
-
### How do I stop Haml from indenting the contents of my `pre` and `textarea` tags?
|
42
|
-
{#q-preserve}
|
33
|
+
### How do I stop Haml from indenting the contents of my `pre` and `textarea` tags? {#q-preserve}
|
43
34
|
|
44
35
|
Because Haml automatically indents the HTML source code,
|
45
36
|
the contents of whitespace-sensitive tags like `pre` and `textarea`
|
@@ -50,7 +41,7 @@ which Haml does using the {Haml::Helpers#preserve} and {Haml::Helpers#find_and_p
|
|
50
41
|
|
51
42
|
Normally, Haml will do this for you automatically
|
52
43
|
when you're using a tag that needs it
|
53
|
-
(this can be customized using the {
|
44
|
+
(this can be customized using the {Haml::Options#preserve `:preserve`} option).
|
54
45
|
For example,
|
55
46
|
|
56
47
|
%p
|
@@ -59,7 +50,8 @@ For example,
|
|
59
50
|
will be compiled to
|
60
51
|
|
61
52
|
<p>
|
62
|
-
<textarea>
|
53
|
+
<textarea>
|
54
|
+
Foo
Bar</textarea>
|
63
55
|
</p>
|
64
56
|
|
65
57
|
However, if a helper is generating the tag,
|
@@ -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/MIT-LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,10 @@
|
|
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
|
+
[](https://coveralls.io/r/haml/haml)
|
7
|
+
[](http://inch-ci.org/github/haml/haml)
|
4
8
|
|
5
9
|
Haml is a templating engine for HTML. It's designed to make it both easier and
|
6
10
|
more pleasant to write HTML documents, by eliminating redundancy, reflecting the
|
@@ -12,23 +16,38 @@ that's both powerful and easy to understand.
|
|
12
16
|
Haml can be used from the command line or as part of a Ruby web framework. The
|
13
17
|
first step is to install the gem:
|
14
18
|
|
15
|
-
|
19
|
+
~~~sh
|
20
|
+
gem install haml
|
21
|
+
~~~
|
16
22
|
|
17
23
|
After you write some Haml, you can run
|
18
24
|
|
19
|
-
|
25
|
+
~~~sh
|
26
|
+
haml document.haml
|
27
|
+
~~~
|
20
28
|
|
21
29
|
to compile it to HTML. For more information on these commands, check out
|
22
30
|
|
23
|
-
|
31
|
+
~~~sh
|
32
|
+
haml --help
|
33
|
+
~~~
|
24
34
|
|
25
|
-
To use Haml programatically, check out the [YARD
|
26
|
-
documentation](http://haml.info/docs/yardoc/).
|
35
|
+
To use Haml programatically, check out the [YARD documentation](http://haml.info/docs/yardoc/).
|
27
36
|
|
28
37
|
## Using Haml with Rails
|
29
38
|
|
30
39
|
To use Haml with Rails, simply add Haml to your Gemfile and run `bundle`.
|
31
40
|
|
41
|
+
~~~ruby
|
42
|
+
gem 'haml'
|
43
|
+
~~~
|
44
|
+
|
45
|
+
Haml 5 will require Rails version 4.0 or later. If you are using Rails 3.x, you should use Haml version 4.0.x:
|
46
|
+
|
47
|
+
~~~ruby
|
48
|
+
gem 'haml', '~> 4.0.5'
|
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,18 +165,19 @@ 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.0.0 and higher, so please make sure your changes run on 2.0+.
|
131
173
|
|
132
174
|
## Team
|
133
175
|
|
134
176
|
### Current Maintainers
|
135
177
|
|
136
|
-
* [Norman Clarke](http://github.com/norman)
|
137
|
-
* [Matt Wildig](http://github.com/mattwildig)
|
138
178
|
* [Akira Matsuda](https://github.com/amatsuda)
|
179
|
+
* [Matt Wildig](https://github.com/mattwildig)
|
180
|
+
* [Tee Parham](https://github.com/teeparham)
|
139
181
|
|
140
182
|
### Alumni
|
141
183
|
|
@@ -143,17 +185,18 @@ Haml was created by [Hampton Catlin](http://hamptoncatlin.com), the author of
|
|
143
185
|
the original implementation. Hampton is no longer involved in day-to-day coding,
|
144
186
|
but still consults on language issues.
|
145
187
|
|
146
|
-
[
|
188
|
+
[Natalie Weizenbaum](http://nex-3.com) was for many years the primary developer
|
147
189
|
and architect of the "modern" Ruby implementation of Haml.
|
148
190
|
|
191
|
+
[Norman Clarke](http://github.com/norman) was the primary maintainer of Haml from 2012 to 2016.
|
149
192
|
|
150
193
|
## License
|
151
194
|
|
152
|
-
Some of
|
195
|
+
Some of Natalie's work on Haml was supported by Unspace Interactive.
|
153
196
|
|
154
197
|
Beyond that, the implementation is licensed under the MIT License.
|
155
198
|
|
156
|
-
Copyright (c) 2006-2013 Hampton Catlin,
|
199
|
+
Copyright (c) 2006-2013 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
|