haml 6.0.0.beta.1-java

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.
Files changed (74) hide show
  1. checksums.yaml +7 -0
  2. data/.github/FUNDING.yml +1 -0
  3. data/.github/workflows/test.yml +40 -0
  4. data/.gitignore +19 -0
  5. data/CHANGELOG.md +1515 -0
  6. data/FAQ.md +147 -0
  7. data/Gemfile +23 -0
  8. data/MIT-LICENSE +20 -0
  9. data/README.md +210 -0
  10. data/REFERENCE.md +1380 -0
  11. data/Rakefile +116 -0
  12. data/bin/bench +66 -0
  13. data/bin/console +11 -0
  14. data/bin/ruby +3 -0
  15. data/bin/setup +7 -0
  16. data/bin/stackprof +27 -0
  17. data/bin/test +24 -0
  18. data/exe/haml +6 -0
  19. data/ext/haml/extconf.rb +10 -0
  20. data/ext/haml/haml.c +537 -0
  21. data/ext/haml/hescape.c +108 -0
  22. data/ext/haml/hescape.h +20 -0
  23. data/haml.gemspec +47 -0
  24. data/lib/haml/ambles.rb +20 -0
  25. data/lib/haml/attribute_builder.rb +175 -0
  26. data/lib/haml/attribute_compiler.rb +128 -0
  27. data/lib/haml/attribute_parser.rb +110 -0
  28. data/lib/haml/cli.rb +154 -0
  29. data/lib/haml/compiler/children_compiler.rb +126 -0
  30. data/lib/haml/compiler/comment_compiler.rb +39 -0
  31. data/lib/haml/compiler/doctype_compiler.rb +46 -0
  32. data/lib/haml/compiler/script_compiler.rb +116 -0
  33. data/lib/haml/compiler/silent_script_compiler.rb +24 -0
  34. data/lib/haml/compiler/tag_compiler.rb +76 -0
  35. data/lib/haml/compiler.rb +97 -0
  36. data/lib/haml/dynamic_merger.rb +67 -0
  37. data/lib/haml/engine.rb +53 -0
  38. data/lib/haml/error.rb +16 -0
  39. data/lib/haml/escapable.rb +13 -0
  40. data/lib/haml/filters/base.rb +12 -0
  41. data/lib/haml/filters/cdata.rb +20 -0
  42. data/lib/haml/filters/coffee.rb +17 -0
  43. data/lib/haml/filters/css.rb +33 -0
  44. data/lib/haml/filters/erb.rb +10 -0
  45. data/lib/haml/filters/escaped.rb +22 -0
  46. data/lib/haml/filters/javascript.rb +33 -0
  47. data/lib/haml/filters/less.rb +20 -0
  48. data/lib/haml/filters/markdown.rb +11 -0
  49. data/lib/haml/filters/plain.rb +29 -0
  50. data/lib/haml/filters/preserve.rb +22 -0
  51. data/lib/haml/filters/ruby.rb +10 -0
  52. data/lib/haml/filters/sass.rb +15 -0
  53. data/lib/haml/filters/scss.rb +15 -0
  54. data/lib/haml/filters/text_base.rb +25 -0
  55. data/lib/haml/filters/tilt_base.rb +49 -0
  56. data/lib/haml/filters.rb +75 -0
  57. data/lib/haml/force_escapable.rb +29 -0
  58. data/lib/haml/haml_error.rb +66 -0
  59. data/lib/haml/helpers.rb +15 -0
  60. data/lib/haml/html.rb +22 -0
  61. data/lib/haml/identity.rb +13 -0
  62. data/lib/haml/object_ref.rb +30 -0
  63. data/lib/haml/parser.rb +986 -0
  64. data/lib/haml/rails_helpers.rb +51 -0
  65. data/lib/haml/rails_template.rb +55 -0
  66. data/lib/haml/railtie.rb +15 -0
  67. data/lib/haml/ruby_expression.rb +32 -0
  68. data/lib/haml/string_splitter.rb +20 -0
  69. data/lib/haml/template.rb +20 -0
  70. data/lib/haml/temple_line_counter.rb +31 -0
  71. data/lib/haml/util.rb +260 -0
  72. data/lib/haml/version.rb +4 -0
  73. data/lib/haml.rb +13 -0
  74. metadata +359 -0
data/FAQ.md ADDED
@@ -0,0 +1,147 @@
1
+ # Frequently Asked Questions
2
+
3
+ ## Haml
4
+
5
+ ### How do I put a punctuation mark after an element, like "`I like <strong>cake</strong>!`"? {#q-punctuation}
6
+
7
+ Expressing the structure of a document
8
+ and expressing inline formatting are two very different problems.
9
+ Haml is mostly designed for structure,
10
+ so the best way to deal with formatting is to leave it to other languages
11
+ that are designed for it.
12
+ You could use Textile:
13
+
14
+ %p
15
+ :textile
16
+ I like *cake*!
17
+
18
+ or Markdown:
19
+
20
+ %p
21
+ :markdown
22
+ I like **cake**!
23
+
24
+ or plain old XHTML:
25
+
26
+ %p I like <strong>cake</strong>!
27
+
28
+ If you're inserting something that's generated by a helper, like a link,
29
+ then it's even easier:
30
+
31
+ %p== I like #{link_to 'chocolate', 'http://franschocolates.com'}!
32
+
33
+ ### How do I stop Haml from indenting the contents of my `pre` and `textarea` tags? {#q-preserve}
34
+
35
+ Because Haml automatically indents the HTML source code,
36
+ the contents of whitespace-sensitive tags like `pre` and `textarea`
37
+ can get screwed up.
38
+ The solution is to replace the newlines inside these tags
39
+ with HTML newline entities (`&#x000A;`),
40
+ which Haml does using the {Haml::Helpers#preserve} and {Haml::Helpers#find_and_preserve} helpers.
41
+
42
+ Normally, Haml will do this for you automatically
43
+ when you're using a tag that needs it
44
+ (this can be customized using the {Haml::Options#preserve `:preserve`} option).
45
+ For example,
46
+
47
+ %p
48
+ %textarea= "Foo\nBar"
49
+
50
+ will be compiled to
51
+
52
+ <p>
53
+ <textarea>
54
+ Foo&#x000A;Bar</textarea>
55
+ </p>
56
+
57
+ However, if a helper is generating the tag,
58
+ Haml can't detect that and so you'll have to call {Haml::Helpers#find_and_preserve} yourself.
59
+ You can also use `~`, which is the same as `=`
60
+ except that it automatically runs `find_and_preserve` on its input.
61
+ For example:
62
+
63
+ %p= find_and_preserve "<textarea>Foo\nBar</textarea>"
64
+
65
+ is the same as
66
+
67
+ %p~ "<textarea>Foo\nBar</textarea>"
68
+
69
+ and renders
70
+
71
+ <p><textarea>Foo&#x000A;Bar</textarea></p>
72
+
73
+ ### How do I make my long lines of Ruby code look nicer in my Haml document? {#q-multiline}
74
+
75
+ Put them in a helper or your model.
76
+
77
+ Haml purposefully makes it annoying to put lots of Ruby code into your templates,
78
+ because lots of code doesn't belong in the view.
79
+ If you take that huge `link_to_remote` call
80
+ and move it to a `update_sidebar_link` helper,
81
+ it'll make your view both easier to read and more semantic.
82
+
83
+ If you absolutely must put lots of code in your template,
84
+ Haml offers a somewhat awkward multiline-continuation tool.
85
+ Put a `|` (pipe character) at the end of each line you want to be merged into one
86
+ (including the last line!).
87
+ For example:
88
+
89
+ %p= @this.is(way.too.much). |
90
+ code("and I should"). |
91
+ really_move.it.into( |
92
+ :a => @helper) |
93
+
94
+ Note that sometimes it is valid to include lots of Ruby in a template
95
+ when that Ruby is a helper call that passes in a lot of template information.
96
+ Thus when a function has lots of arguments,
97
+ it's possible to wrap it across multiple lines
98
+ as long as each line ends in a comma.
99
+ For example:
100
+
101
+ = link_to_remote "Add to cart",
102
+ :url => { :action => "add", :id => product.id },
103
+ :update => { :success => "cart", :failure => "error" }
104
+
105
+ ### `form_for` is printing the form tag twice!
106
+
107
+ Make sure you're calling it with `-`, not `=`.
108
+ Just like in ERB, you have to do
109
+
110
+ <% form_for stuff do %>
111
+ ...
112
+ <% end %>
113
+
114
+ in Haml, you have to do
115
+
116
+ - form_for stuff do
117
+ ...
118
+
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}
120
+
121
+ There are several reasons these things might be happening.
122
+ First of all, make sure that Haml really is installed;
123
+ either you've loaded the gem (via `config.gem` in Rails 2.3 or in the Gemfile in Rails 3),
124
+ or `vendor/plugins/haml` exists and contains files.
125
+ Then try restarting Mongrel or WEBrick or whatever you might be using.
126
+
127
+ Finally, if none of these work,
128
+ chances are you've got some localization plugin like Globalize installed.
129
+ Such plugins often don't play nicely with Haml.
130
+ Luckily, there's usually an easy fix.
131
+ For Globalize, just edit `globalize/lib/globalize/rails/action_view.rb`
132
+ and change
133
+
134
+ @@re_extension = /\.(rjs|rhtml|rxml)$/
135
+
136
+ to
137
+
138
+ @@re_extension = /\.(rjs|rhtml|rxml|erb|builder|haml)$/
139
+
140
+ For other plugins, a little searching will probably turn up a way to fix them as well.
141
+
142
+ ## You still haven't answered my question!
143
+
144
+ Sorry! Try looking at the [Haml](http://haml.info/docs/yardoc/file.REFERENCE.html) reference,
145
+ If you can't find an answer there,
146
+ feel free to ask in `#haml` on irc.freenode.net
147
+ or send an email to the [mailing list](http://groups.google.com/group/haml).
data/Gemfile ADDED
@@ -0,0 +1,23 @@
1
+ source 'https://rubygems.org'
2
+
3
+ git_source(:github) do |repo_name|
4
+ repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
5
+ "https://github.com/#{repo_name}.git"
6
+ end
7
+
8
+ # Specify your gem's dependencies in haml.gemspec
9
+ gemspec
10
+
11
+ gem 'benchmark-ips', '2.3.0'
12
+ gem 'maxitest'
13
+ gem 'pry'
14
+
15
+ if /java/ === RUBY_PLATFORM # JRuby
16
+ gem 'pandoc-ruby'
17
+ else
18
+ gem 'redcarpet'
19
+
20
+ if RUBY_PLATFORM !~ /mswin|mingw/ && RUBY_ENGINE != 'truffleruby'
21
+ gem 'stackprof'
22
+ end
23
+ end
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2006-2021 Hampton Catlin, Natalie Weizenbaum and Takashi Kokubun
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
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.
data/README.md ADDED
@@ -0,0 +1,210 @@
1
+ # Haml
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/haml.svg)](http://rubygems.org/gems/haml)
4
+ [![Build Status](https://travis-ci.org/haml/haml.svg?branch=main)](http://travis-ci.org/haml/haml)
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)
7
+
8
+ Haml is a templating engine for HTML. It's designed to make it both easier and
9
+ more pleasant to write HTML documents, by eliminating redundancy, reflecting the
10
+ underlying structure that the document represents, and providing an elegant syntax
11
+ that's both powerful and easy to understand.
12
+
13
+ ## Basic Usage
14
+
15
+ Haml can be used from the command line or as part of a Ruby web framework. The
16
+ first step is to install the gem:
17
+
18
+ ~~~sh
19
+ gem install haml
20
+ ~~~
21
+
22
+ After you write some Haml, you can run
23
+
24
+ ~~~sh
25
+ haml document.haml
26
+ ~~~
27
+
28
+ to compile it to HTML. For more information on these commands, check out
29
+
30
+ ~~~sh
31
+ haml --help
32
+ ~~~
33
+
34
+ To use Haml programmatically, check out the [YARD documentation](http://haml.info/docs/yardoc/).
35
+
36
+ ## Using Haml with Rails
37
+
38
+ To use Haml with Rails, simply add Haml to your Gemfile and run `bundle`.
39
+
40
+ ~~~ruby
41
+ gem 'haml'
42
+ ~~~
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.
46
+
47
+ ## Formatting
48
+
49
+ The most basic element of Haml is a shorthand for creating HTML:
50
+
51
+ ~~~haml
52
+ %tagname{:attr1 => 'value1', :attr2 => 'value2'} Contents
53
+ ~~~
54
+
55
+ No end-tag is needed; Haml handles that automatically. If you prefer HTML-style
56
+ attributes, you can also use:
57
+
58
+ ~~~haml
59
+ %tagname(attr1='value1' attr2='value2') Contents
60
+ ~~~
61
+
62
+ Adding `class` and `id` attributes is even easier. Haml uses the same syntax as
63
+ the CSS that styles the document:
64
+
65
+ ~~~haml
66
+ %tagname#id.class
67
+ ~~~
68
+
69
+ In fact, when you're using the `<div>` tag, it becomes _even easier_. Because
70
+ `<div>` is such a common element, a tag without a name defaults to a div. So
71
+
72
+ ~~~haml
73
+ #foo Hello!
74
+ ~~~
75
+
76
+ becomes
77
+
78
+ ~~~html
79
+ <div id='foo'>Hello!</div>
80
+ ~~~
81
+
82
+ Haml uses indentation to bring the individual elements to represent the HTML
83
+ structure. A tag's children are indented beneath than the parent tag. Again, a
84
+ closing tag is automatically added. For example:
85
+
86
+ ~~~haml
87
+ %ul
88
+ %li Salt
89
+ %li Pepper
90
+ ~~~
91
+
92
+ becomes:
93
+
94
+ ~~~html
95
+ <ul>
96
+ <li>Salt</li>
97
+ <li>Pepper</li>
98
+ </ul>
99
+ ~~~
100
+
101
+ You can also put plain text as a child of an element:
102
+
103
+ ~~~haml
104
+ %p
105
+ Hello,
106
+ World!
107
+ ~~~
108
+
109
+ It's also possible to embed Ruby code into Haml documents. An equals sign, `=`,
110
+ will output the result of the code. A hyphen, `-`, will run the code but not
111
+ output the result. You can even use control statements like `if` and `while`:
112
+
113
+ ~~~haml
114
+ %p
115
+ Date/Time:
116
+ - now = DateTime.now
117
+ %strong= now
118
+ - if now > DateTime.parse("December 31, 2006")
119
+ = "Happy new " + "year!"
120
+ ~~~
121
+
122
+ Haml provides far more tools than those presented here. Check out the [reference
123
+ documentation](http://haml.info/docs/yardoc/file.REFERENCE.html)
124
+ for full details.
125
+
126
+ ### Indentation
127
+
128
+ Haml's indentation can be made up of one or more tabs or spaces. However,
129
+ indentation must be consistent within a given document. Hard tabs and spaces
130
+ can't be mixed, and the same number of tabs or spaces must be used throughout.
131
+
132
+ ## Contributing
133
+
134
+ Contributions are welcomed, but before you get started please read the
135
+ [guidelines](http://haml.info/development.html#contributing).
136
+
137
+ After forking and then cloning the repo locally, install Bundler and then use it
138
+ to install the development gem dependencies:
139
+ ~~~sh
140
+ gem install bundler
141
+ bundle install
142
+ ~~~
143
+
144
+ Once this is complete, you should be able to run the test suite:
145
+ ~~~sh
146
+ rake
147
+ ~~~
148
+
149
+ You'll get a warning that you need to install haml-spec, so run this:
150
+
151
+ ~~~sh
152
+ git submodule update --init
153
+ ~~~
154
+
155
+ At this point `rake` should run without error or warning and you are ready to
156
+ start working on your patch!
157
+
158
+ Note that you can also run just one test out of the test suite if you're working
159
+ on a specific area:
160
+
161
+ ~~~sh
162
+ ruby -Itest test/helper_test.rb -n test_buffer_access
163
+ ~~~
164
+
165
+ Haml currently supports Ruby 2.0.0 and higher, so please make sure your changes run on 2.0+.
166
+
167
+ ## Team
168
+
169
+ ### Current Maintainers
170
+
171
+ * [Akira Matsuda](https://github.com/amatsuda)
172
+ * [Matt Wildig](https://github.com/mattwildig)
173
+ * [Tee Parham](https://github.com/teeparham)
174
+ * [Takashi Kokubun](https://github.com/k0kubun)
175
+
176
+ ### Alumni
177
+
178
+ Haml was created by [Hampton Catlin](http://hamptoncatlin.com), the author of
179
+ the original implementation. Hampton is no longer involved in day-to-day coding,
180
+ but still consults on language issues.
181
+
182
+ [Natalie Weizenbaum](http://nex-3.com) was for many years the primary developer
183
+ and architect of the "modern" Ruby implementation of Haml.
184
+
185
+ [Norman Clarke](http://github.com/norman) was the primary maintainer of Haml from 2012 to 2016.
186
+
187
+ ## License
188
+
189
+ Some of Natalie's work on Haml was supported by Unspace Interactive.
190
+
191
+ Beyond that, the implementation is licensed under the MIT License.
192
+
193
+ Copyright (c) 2006-2019 Hampton Catlin, Natalie Weizenbaum and the Haml team
194
+
195
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
196
+ this software and associated documentation files (the "Software"), to deal in
197
+ the Software without restriction, including without limitation the rights to
198
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
199
+ the Software, and to permit persons to whom the Software is furnished to do so,
200
+ subject to the following conditions:
201
+
202
+ The above copyright notice and this permission notice shall be included in all
203
+ copies or substantial portions of the Software.
204
+
205
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
206
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
207
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
208
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
209
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
210
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.