haml 1.8.0 → 2.0.3

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 (89) hide show
  1. data/FAQ +138 -0
  2. data/MIT-LICENSE +1 -1
  3. data/{README → README.rdoc} +66 -3
  4. data/REVISION +1 -0
  5. data/Rakefile +115 -147
  6. data/VERSION +1 -1
  7. data/bin/css2sass +0 -0
  8. data/bin/haml +2 -1
  9. data/bin/html2haml +0 -0
  10. data/bin/sass +0 -0
  11. data/init.rb +6 -1
  12. data/lib/haml/buffer.rb +122 -64
  13. data/lib/haml/engine.rb +77 -46
  14. data/lib/haml/error.rb +15 -6
  15. data/lib/haml/exec.rb +61 -10
  16. data/lib/haml/filters.rb +229 -74
  17. data/lib/haml/helpers/action_view_extensions.rb +1 -1
  18. data/lib/haml/helpers/action_view_mods.rb +109 -24
  19. data/lib/haml/helpers.rb +137 -76
  20. data/lib/haml/html.rb +8 -8
  21. data/lib/haml/precompiler.rb +280 -153
  22. data/lib/haml/template/patch.rb +10 -3
  23. data/lib/haml/template/plugin.rb +61 -10
  24. data/lib/haml/template.rb +14 -9
  25. data/lib/haml.rb +483 -214
  26. data/lib/sass/constant/color.rb +13 -13
  27. data/lib/sass/constant/literal.rb +8 -7
  28. data/lib/sass/constant/nil.rb +9 -0
  29. data/lib/sass/constant/number.rb +10 -10
  30. data/lib/sass/constant/operation.rb +4 -4
  31. data/lib/sass/constant/string.rb +3 -3
  32. data/lib/sass/constant.rb +46 -77
  33. data/lib/sass/css.rb +130 -56
  34. data/lib/sass/engine.rb +131 -43
  35. data/lib/sass/plugin/merb.rb +48 -12
  36. data/lib/sass/plugin/rails.rb +10 -4
  37. data/lib/sass/plugin.rb +33 -10
  38. data/lib/sass/tree/attr_node.rb +5 -5
  39. data/lib/sass/tree/directive_node.rb +2 -7
  40. data/lib/sass/tree/node.rb +1 -12
  41. data/lib/sass/tree/rule_node.rb +39 -31
  42. data/lib/sass/tree/value_node.rb +1 -1
  43. data/lib/sass.rb +194 -19
  44. data/rails/init.rb +1 -0
  45. data/test/benchmark.rb +67 -80
  46. data/test/haml/engine_test.rb +368 -152
  47. data/test/haml/helper_test.rb +68 -16
  48. data/test/haml/html2haml_test.rb +3 -4
  49. data/test/haml/results/content_for_layout.xhtml +1 -2
  50. data/test/haml/results/eval_suppressed.xhtml +2 -4
  51. data/test/haml/results/filters.xhtml +38 -30
  52. data/test/haml/results/helpers.xhtml +4 -8
  53. data/test/haml/results/just_stuff.xhtml +8 -7
  54. data/test/haml/results/nuke_inner_whitespace.xhtml +40 -0
  55. data/test/haml/results/nuke_outer_whitespace.xhtml +148 -0
  56. data/test/haml/results/original_engine.xhtml +3 -7
  57. data/test/haml/results/partials.xhtml +1 -0
  58. data/test/haml/results/tag_parsing.xhtml +1 -6
  59. data/test/haml/results/very_basic.xhtml +2 -4
  60. data/test/haml/results/whitespace_handling.xhtml +13 -21
  61. data/test/haml/template_test.rb +42 -57
  62. data/test/haml/templates/_partial.haml +1 -0
  63. data/test/haml/templates/filters.haml +39 -21
  64. data/test/haml/templates/helpers.haml +10 -10
  65. data/test/haml/templates/just_stuff.haml +8 -3
  66. data/test/haml/templates/nuke_inner_whitespace.haml +32 -0
  67. data/test/haml/templates/nuke_outer_whitespace.haml +144 -0
  68. data/test/haml/templates/partials.haml +1 -1
  69. data/test/haml/templates/tag_parsing.haml +0 -3
  70. data/test/haml/templates/whitespace_handling.haml +10 -10
  71. data/test/sass/engine_test.rb +97 -39
  72. data/test/sass/plugin_test.rb +4 -7
  73. data/test/sass/results/constants.css +2 -0
  74. data/test/sass/results/import.css +2 -2
  75. data/test/sass/results/mixins.css +95 -0
  76. data/test/sass/results/multiline.css +24 -0
  77. data/test/sass/templates/constants.sass +3 -0
  78. data/test/sass/templates/import.sass +4 -1
  79. data/test/sass/templates/importee.sass +4 -0
  80. data/test/sass/templates/mixins.sass +76 -0
  81. data/test/sass/templates/multiline.sass +20 -0
  82. data/test/test_helper.rb +18 -0
  83. metadata +70 -53
  84. data/lib/haml/helpers/action_view_mods.rb.rej +0 -30
  85. data/lib/haml/util.rb +0 -18
  86. data/lib/sass/constant.rb.rej +0 -42
  87. data/test/haml/runner.rb +0 -16
  88. data/test/profile.rb +0 -65
  89. data/test/sass/engine_test.rb.rej +0 -18
metadata CHANGED
@@ -1,42 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.4
3
- specification_version: 1
4
2
  name: haml
5
3
  version: !ruby/object:Gem::Version
6
- version: 1.8.0
7
- date: 2008-01-06 00:00:00 -08:00
8
- summary: An elegant, structured XHTML/XML templating engine. Comes with Sass, a similar CSS templating engine.
9
- require_paths:
10
- - lib
11
- email: haml@googlegroups.com
12
- homepage: http://haml.hamptoncatlin.com/
13
- rubyforge_project:
14
- description: Haml (HTML Abstraction Markup Language) is a layer on top of XHTML or XML that's designed to express the structure of XHTML or XML documents in a non-repetitive, elegant, easy way, using indentation rather than closing tags and allowing Ruby to be embedded with ease. It was originally envisioned as a plugin for Ruby on Rails, but it can function as a stand-alone templating engine.
15
- autorequire:
16
- - haml
17
- - sass
18
- default_executable:
19
- bindir: bin
20
- has_rdoc: true
21
- required_ruby_version: !ruby/object:Gem::Version::Requirement
22
- requirements:
23
- - - ">"
24
- - !ruby/object:Gem::Version
25
- version: 0.0.0
26
- version:
4
+ version: 2.0.3
27
5
  platform: ruby
28
- signing_key:
29
- cert_chain:
30
- post_install_message:
31
6
  authors:
7
+ - Nathan Weizenbaum
32
8
  - Hampton Catlin
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2008-09-07 00:00:00 -07:00
14
+ default_executable:
15
+ dependencies: []
16
+
17
+ description: Haml (HTML Abstraction Markup Language) is a layer on top of XHTML or XML that's designed to express the structure of XHTML or XML documents in a non-repetitive, elegant, easy way, using indentation rather than closing tags and allowing Ruby to be embedded with ease. It was originally envisioned as a plugin for Ruby on Rails, but it can function as a stand-alone templating engine.
18
+ email: haml@googlegroups.com
19
+ executables:
20
+ - haml
21
+ - html2haml
22
+ - sass
23
+ - css2sass
24
+ extensions: []
25
+
26
+ extra_rdoc_files:
27
+ - VERSION
28
+ - MIT-LICENSE
29
+ - README.rdoc
30
+ - FAQ
31
+ - REVISION
33
32
  files:
33
+ - rails/init.rb
34
34
  - lib/sass.rb
35
35
  - lib/sass
36
36
  - lib/sass/plugin
37
37
  - lib/sass/plugin/rails.rb
38
38
  - lib/sass/plugin/merb.rb
39
- - lib/sass/constant.rb.rej
40
39
  - lib/sass/error.rb
41
40
  - lib/sass/tree
42
41
  - lib/sass/tree/value_node.rb
@@ -52,11 +51,11 @@ files:
52
51
  - lib/sass/constant/number.rb
53
52
  - lib/sass/constant/operation.rb
54
53
  - lib/sass/constant/literal.rb
54
+ - lib/sass/constant/nil.rb
55
55
  - lib/sass/plugin.rb
56
56
  - lib/sass/css.rb
57
57
  - lib/sass/engine.rb
58
58
  - lib/haml
59
- - lib/haml/util.rb
60
59
  - lib/haml/exec.rb
61
60
  - lib/haml/html.rb
62
61
  - lib/haml/error.rb
@@ -71,7 +70,6 @@ files:
71
70
  - lib/haml/precompiler.rb
72
71
  - lib/haml/helpers
73
72
  - lib/haml/helpers/action_view_extensions.rb
74
- - lib/haml/helpers/action_view_mods.rb.rej
75
73
  - lib/haml/helpers/action_view_mods.rb
76
74
  - lib/haml.rb
77
75
  - bin/css2sass
@@ -90,6 +88,8 @@ files:
90
88
  - test/sass/templates/subdir/nested_subdir/nested_subdir.sass
91
89
  - test/sass/templates/basic.sass
92
90
  - test/sass/templates/_partial.sass
91
+ - test/sass/templates/mixins.sass
92
+ - test/sass/templates/multiline.sass
93
93
  - test/sass/templates/nested.sass
94
94
  - test/sass/templates/compact.sass
95
95
  - test/sass/templates/alt.sass
@@ -109,12 +109,13 @@ files:
109
109
  - test/sass/results/compact.css
110
110
  - test/sass/results/expanded.css
111
111
  - test/sass/results/alt.css
112
+ - test/sass/results/mixins.css
112
113
  - test/sass/results/complex.css
113
114
  - test/sass/results/constants.css
114
115
  - test/sass/results/compressed.css
115
116
  - test/sass/results/parent_ref.css
117
+ - test/sass/results/multiline.css
116
118
  - test/sass/results/basic.css
117
- - test/sass/engine_test.rb.rej
118
119
  - test/sass/engine_test.rb
119
120
  - test/haml
120
121
  - test/haml/mocks
@@ -131,11 +132,13 @@ files:
131
132
  - test/haml/templates/list.haml
132
133
  - test/haml/templates/_text_area.haml
133
134
  - test/haml/templates/_partial.haml
135
+ - test/haml/templates/nuke_outer_whitespace.haml
134
136
  - test/haml/templates/_av_partial_2.haml
135
137
  - test/haml/templates/helpful.haml
136
138
  - test/haml/templates/just_stuff.haml
137
139
  - test/haml/templates/silent_script.haml
138
140
  - test/haml/templates/very_basic.haml
141
+ - test/haml/templates/nuke_inner_whitespace.haml
139
142
  - test/haml/templates/eval_suppressed.haml
140
143
  - test/haml/templates/tag_parsing.haml
141
144
  - test/haml/templates/whitespace_handling.haml
@@ -149,14 +152,15 @@ files:
149
152
  - test/haml/templates/original_engine.haml
150
153
  - test/haml/templates/breakage.haml
151
154
  - test/haml/templates/action_view.haml
152
- - test/haml/runner.rb
153
155
  - test/haml/results
154
156
  - test/haml/results/content_for_layout.xhtml
155
157
  - test/haml/results/just_stuff.xhtml
156
158
  - test/haml/results/whitespace_handling.xhtml
159
+ - test/haml/results/nuke_outer_whitespace.xhtml
157
160
  - test/haml/results/silent_script.xhtml
158
161
  - test/haml/results/filters.xhtml
159
162
  - test/haml/results/standard.xhtml
163
+ - test/haml/results/nuke_inner_whitespace.xhtml
160
164
  - test/haml/results/helpful.xhtml
161
165
  - test/haml/results/very_basic.xhtml
162
166
  - test/haml/results/eval_suppressed.xhtml
@@ -168,40 +172,53 @@ files:
168
172
  - test/haml/markaby
169
173
  - test/haml/markaby/standard.mab
170
174
  - test/haml/engine_test.rb
171
- - test/profile.rb
175
+ - test/rails
172
176
  - test/benchmark.rb
177
+ - test/test_helper.rb
173
178
  - Rakefile
174
179
  - init.rb
175
180
  - VERSION
176
181
  - MIT-LICENSE
177
- - README
178
- test_files:
179
- - test/sass/plugin_test.rb
180
- - test/sass/engine_test.rb
181
- - test/haml/template_test.rb
182
- - test/haml/html2haml_test.rb
183
- - test/haml/helper_test.rb
184
- - test/haml/engine_test.rb
182
+ - README.rdoc
183
+ - FAQ
184
+ - REVISION
185
+ has_rdoc: true
186
+ homepage: http://haml.hamptoncatlin.com/
187
+ post_install_message:
185
188
  rdoc_options:
186
189
  - --title
187
190
  - Haml
188
191
  - --main
189
- - README
192
+ - README.rdoc
190
193
  - --exclude
191
194
  - lib/haml/buffer.rb
192
195
  - --line-numbers
193
196
  - --inline-source
194
- extra_rdoc_files:
195
- - VERSION
196
- - MIT-LICENSE
197
- - README
198
- executables:
199
- - haml
200
- - html2haml
201
- - sass
202
- extensions: []
203
-
197
+ require_paths:
198
+ - lib
199
+ required_ruby_version: !ruby/object:Gem::Requirement
200
+ requirements:
201
+ - - ">="
202
+ - !ruby/object:Gem::Version
203
+ version: "0"
204
+ version:
205
+ required_rubygems_version: !ruby/object:Gem::Requirement
206
+ requirements:
207
+ - - ">="
208
+ - !ruby/object:Gem::Version
209
+ version: "0"
210
+ version:
204
211
  requirements: []
205
212
 
206
- dependencies: []
207
-
213
+ rubyforge_project: haml
214
+ rubygems_version: 1.1.1
215
+ signing_key:
216
+ specification_version: 2
217
+ summary: An elegant, structured XHTML/XML templating engine. Comes with Sass, a similar CSS templating engine.
218
+ test_files:
219
+ - test/sass/plugin_test.rb
220
+ - test/sass/engine_test.rb
221
+ - test/haml/template_test.rb
222
+ - test/haml/html2haml_test.rb
223
+ - test/haml/helper_test.rb
224
+ - test/haml/engine_test.rb
@@ -1,30 +0,0 @@
1
- ***************
2
- *** 1,11 ****
3
- - begin
4
- - require 'rubygems'
5
- - require 'active_support'
6
- - require 'action_controller'
7
- - require 'action_view'
8
- - action_view_included = true
9
- - rescue LoadError
10
- - action_view_included = false
11
- end
12
-
13
-
14
- --- 1,16 ----
15
- +
16
- + # This obviously requires that ActiveSupport be present prior to Haml
17
- + # being loaded.
18
- + action_view_included = false
19
- + if defined?(ActiveSupport)
20
- + begin
21
- + require 'rubygems'
22
- + require 'active_support'
23
- + require 'action_controller'
24
- + require 'action_view'
25
- + action_view_included = true
26
- + rescue LoadError
27
- + end
28
- end
29
-
30
-
data/lib/haml/util.rb DELETED
@@ -1,18 +0,0 @@
1
- # This file contains various useful bits of code
2
- # that are shared between Haml and Sass.
3
-
4
- class Hash # :nodoc:
5
- # Same as Hash#merge!,
6
- # but recursively merges sub-hashes
7
- def rec_merge!(other)
8
- other.each do |key, value|
9
- myval = self[key]
10
- if value.is_a?(Hash) && myval.is_a?(Hash)
11
- myval.rec_merge!(value)
12
- else
13
- self[key] = value
14
- end
15
- end
16
- self
17
- end
18
- end
@@ -1,42 +0,0 @@
1
- ***************
2
- *** 106,121 ****
3
- end
4
-
5
- # Time for a unary minus!
6
- - if negative_okay && symbol == :minus
7
- - negative_okay = true
8
- to_return << :neg
9
- next
10
- end
11
-
12
- # Are we looking at an operator?
13
- if symbol && (str.empty? || symbol != :mod)
14
- str = reset_str.call
15
- - negative_okay = true
16
- to_return << symbol
17
- next
18
- end
19
- --- 107,129 ----
20
- end
21
-
22
- # Time for a unary minus!
23
- + if beginning_of_token && symbol == :minus
24
- + beginning_of_token = true
25
- to_return << :neg
26
- next
27
- end
28
-
29
- + # Is this a constant?
30
- + if beginning_of_token && symbol == :const
31
- + beginning_of_token = true
32
- + to_return << :const
33
- + next
34
- + end
35
- +
36
- # Are we looking at an operator?
37
- if symbol && (str.empty? || symbol != :mod)
38
- str = reset_str.call
39
- + beginning_of_token = true
40
- to_return << symbol
41
- next
42
- end
data/test/haml/runner.rb DELETED
@@ -1,16 +0,0 @@
1
- require 'rubygems'
2
- require 'active_support'
3
- require 'action_controller'
4
- require 'action_view'
5
- require '../../lib/haml/template'
6
- require 'fileutils'
7
-
8
- haml_template_engine = Haml::Template.new(ActionView::Base.new)
9
- haml_template_engine.render(File.dirname(__FILE__) + '/templates/standard.haml')
10
-
11
- begin
12
- eval(File.read("template_test.rb"))
13
- rescue StandardError => e
14
- puts e.backtrace
15
- puts e.inspect
16
- end
data/test/profile.rb DELETED
@@ -1,65 +0,0 @@
1
- require 'rubygems'
2
- require 'active_support'
3
- require 'action_controller'
4
- require 'action_view'
5
-
6
- require File.dirname(__FILE__) + '/../lib/haml'
7
- require 'haml/template'
8
-
9
- require 'profiler'
10
- require 'stringio'
11
-
12
- module Haml
13
- # Used by both Haml::Profiler and Sass::Profiler.
14
- # Encapsulates profiling behavior.
15
- module AbstractProfiler
16
- def self.profile(times, &block)
17
- # Runs the profiler, collects information
18
- Profiler__::start_profile
19
- times.times &block
20
- Profiler__::stop_profile
21
-
22
- # Outputs information to a StringIO, returns result
23
- io = StringIO.new
24
- Profiler__::print_profile(io)
25
- io.pos = 0
26
- result = io.read
27
- io.close
28
- result
29
- end
30
- end
31
-
32
- # A profiler for Haml, mostly for development use. This simply implements
33
- # the Ruby profiler for profiling haml code.
34
- class Profiler
35
-
36
- # Creates a new profiler that looks for templates in the base
37
- # directory.
38
- def initialize(base = File.join(File.dirname(__FILE__), 'haml', 'templates'))
39
- unless base.class == ActionView::Base
40
- @base = ActionView::Base.new(base)
41
- else
42
- @base = base
43
- end
44
- end
45
-
46
- # Profiles haml on the given template with the given number of runs.
47
- # The template name shouldn't have a file extension; this will
48
- # automatically look for a haml template.
49
- #
50
- # Returns the results of the profiling as a string.
51
- def profile(runs = 100, template_name = 'standard')
52
- AbstractProfiler.profile(runs) { @base.render template_name }
53
- end
54
- end
55
- end
56
-
57
- module Sass
58
- class Profiler
59
- def profile(runs = 100, template_name = 'complex')
60
- Haml::AbstractProfiler.profile(runs) do
61
- Sass::Engine.new("#{File.dirname(__FILE__)}/sass/templates/#{template_name}.sass").render
62
- end
63
- end
64
- end
65
- end
@@ -1,18 +0,0 @@
1
- ***************
2
- *** 44,49 ****
3
- "@import templates/basic\n foo" => "Illegal nesting: Nothing may be nested beneath import directives.",
4
- "foo\n @import templates/basic" => "Import directives may only be used at the root of a document.",
5
- "@foo bar boom" => "Unknown compiler directive: \"@foo bar boom\"",
6
- }
7
-
8
- def test_basic_render
9
- --- 44,52 ----
10
- "@import templates/basic\n foo" => "Illegal nesting: Nothing may be nested beneath import directives.",
11
- "foo\n @import templates/basic" => "Import directives may only be used at the root of a document.",
12
- "@foo bar boom" => "Unknown compiler directive: \"@foo bar boom\"",
13
- + "!foo = bar baz -" => "Unterminated unary minus.",
14
- + "!foo = bar baz !" => "Unterminated constant.",
15
- + "!foo = !(foo)" => "Invalid constant.",
16
- }
17
-
18
- def test_basic_render