haml 1.8.0 → 2.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.
Files changed (82) hide show
  1. data/FAQ +138 -0
  2. data/MIT-LICENSE +1 -1
  3. data/{README → README.rdoc} +66 -3
  4. data/Rakefile +111 -147
  5. data/VERSION +1 -1
  6. data/bin/css2sass +0 -0
  7. data/bin/haml +0 -0
  8. data/bin/html2haml +0 -0
  9. data/bin/sass +0 -0
  10. data/init.rb +6 -1
  11. data/lib/haml/buffer.rb +121 -63
  12. data/lib/haml/engine.rb +67 -44
  13. data/lib/haml/error.rb +16 -6
  14. data/lib/haml/exec.rb +37 -7
  15. data/lib/haml/filters.rb +213 -68
  16. data/lib/haml/helpers/action_view_extensions.rb +1 -1
  17. data/lib/haml/helpers/action_view_mods.rb +57 -9
  18. data/lib/haml/helpers.rb +105 -61
  19. data/lib/haml/html.rb +6 -6
  20. data/lib/haml/precompiler.rb +268 -132
  21. data/lib/haml/template/patch.rb +9 -2
  22. data/lib/haml/template/plugin.rb +61 -10
  23. data/lib/haml/template.rb +3 -6
  24. data/lib/haml.rb +464 -201
  25. data/lib/sass/constant/color.rb +13 -13
  26. data/lib/sass/constant/literal.rb +7 -7
  27. data/lib/sass/constant/number.rb +9 -9
  28. data/lib/sass/constant/operation.rb +4 -4
  29. data/lib/sass/constant/string.rb +3 -3
  30. data/lib/sass/constant.rb +22 -22
  31. data/lib/sass/css.rb +104 -31
  32. data/lib/sass/engine.rb +120 -39
  33. data/lib/sass/error.rb +1 -1
  34. data/lib/sass/plugin/merb.rb +48 -12
  35. data/lib/sass/plugin/rails.rb +10 -4
  36. data/lib/sass/plugin.rb +22 -3
  37. data/lib/sass/tree/attr_node.rb +5 -5
  38. data/lib/sass/tree/directive_node.rb +2 -7
  39. data/lib/sass/tree/node.rb +1 -12
  40. data/lib/sass/tree/rule_node.rb +39 -31
  41. data/lib/sass/tree/value_node.rb +1 -1
  42. data/lib/sass.rb +157 -12
  43. data/test/benchmark.rb +67 -80
  44. data/test/haml/engine_test.rb +318 -81
  45. data/test/haml/helper_test.rb +52 -16
  46. data/test/haml/results/content_for_layout.xhtml +1 -2
  47. data/test/haml/results/eval_suppressed.xhtml +2 -4
  48. data/test/haml/results/filters.xhtml +44 -15
  49. data/test/haml/results/helpers.xhtml +2 -3
  50. data/test/haml/results/just_stuff.xhtml +2 -6
  51. data/test/haml/results/nuke_inner_whitespace.xhtml +34 -0
  52. data/test/haml/results/nuke_outer_whitespace.xhtml +148 -0
  53. data/test/haml/results/original_engine.xhtml +3 -7
  54. data/test/haml/results/partials.xhtml +1 -0
  55. data/test/haml/results/tag_parsing.xhtml +1 -6
  56. data/test/haml/results/very_basic.xhtml +2 -4
  57. data/test/haml/results/whitespace_handling.xhtml +13 -21
  58. data/test/haml/template_test.rb +8 -15
  59. data/test/haml/templates/_partial.haml +1 -0
  60. data/test/haml/templates/filters.haml +48 -7
  61. data/test/haml/templates/helpers.haml +9 -9
  62. data/test/haml/templates/just_stuff.haml +1 -2
  63. data/test/haml/templates/nuke_inner_whitespace.haml +26 -0
  64. data/test/haml/templates/nuke_outer_whitespace.haml +144 -0
  65. data/test/haml/templates/tag_parsing.haml +0 -3
  66. data/test/haml/test_helper.rb +15 -0
  67. data/test/sass/engine_test.rb +84 -34
  68. data/test/sass/plugin_test.rb +1 -1
  69. data/test/sass/results/import.css +2 -2
  70. data/test/sass/results/mixins.css +95 -0
  71. data/test/sass/results/multiline.css +24 -0
  72. data/test/sass/templates/import.sass +4 -1
  73. data/test/sass/templates/importee.sass +4 -0
  74. data/test/sass/templates/mixins.sass +76 -0
  75. data/test/sass/templates/multiline.sass +20 -0
  76. metadata +65 -53
  77. data/lib/haml/helpers/action_view_mods.rb.rej +0 -30
  78. data/lib/haml/util.rb +0 -18
  79. data/lib/sass/constant.rb.rej +0 -42
  80. data/test/haml/runner.rb +0 -16
  81. data/test/profile.rb +0 -65
  82. data/test/sass/engine_test.rb.rej +0 -18
metadata CHANGED
@@ -1,42 +1,39 @@
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.0
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-05-23 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
33
31
  files:
34
32
  - lib/sass.rb
35
33
  - lib/sass
36
34
  - lib/sass/plugin
37
35
  - lib/sass/plugin/rails.rb
38
36
  - lib/sass/plugin/merb.rb
39
- - lib/sass/constant.rb.rej
40
37
  - lib/sass/error.rb
41
38
  - lib/sass/tree
42
39
  - lib/sass/tree/value_node.rb
@@ -56,7 +53,6 @@ files:
56
53
  - lib/sass/css.rb
57
54
  - lib/sass/engine.rb
58
55
  - lib/haml
59
- - lib/haml/util.rb
60
56
  - lib/haml/exec.rb
61
57
  - lib/haml/html.rb
62
58
  - lib/haml/error.rb
@@ -71,7 +67,6 @@ files:
71
67
  - lib/haml/precompiler.rb
72
68
  - lib/haml/helpers
73
69
  - lib/haml/helpers/action_view_extensions.rb
74
- - lib/haml/helpers/action_view_mods.rb.rej
75
70
  - lib/haml/helpers/action_view_mods.rb
76
71
  - lib/haml.rb
77
72
  - bin/css2sass
@@ -90,6 +85,8 @@ files:
90
85
  - test/sass/templates/subdir/nested_subdir/nested_subdir.sass
91
86
  - test/sass/templates/basic.sass
92
87
  - test/sass/templates/_partial.sass
88
+ - test/sass/templates/mixins.sass
89
+ - test/sass/templates/multiline.sass
93
90
  - test/sass/templates/nested.sass
94
91
  - test/sass/templates/compact.sass
95
92
  - test/sass/templates/alt.sass
@@ -109,12 +106,13 @@ files:
109
106
  - test/sass/results/compact.css
110
107
  - test/sass/results/expanded.css
111
108
  - test/sass/results/alt.css
109
+ - test/sass/results/mixins.css
112
110
  - test/sass/results/complex.css
113
111
  - test/sass/results/constants.css
114
112
  - test/sass/results/compressed.css
115
113
  - test/sass/results/parent_ref.css
114
+ - test/sass/results/multiline.css
116
115
  - test/sass/results/basic.css
117
- - test/sass/engine_test.rb.rej
118
116
  - test/sass/engine_test.rb
119
117
  - test/haml
120
118
  - test/haml/mocks
@@ -131,11 +129,13 @@ files:
131
129
  - test/haml/templates/list.haml
132
130
  - test/haml/templates/_text_area.haml
133
131
  - test/haml/templates/_partial.haml
132
+ - test/haml/templates/nuke_outer_whitespace.haml
134
133
  - test/haml/templates/_av_partial_2.haml
135
134
  - test/haml/templates/helpful.haml
136
135
  - test/haml/templates/just_stuff.haml
137
136
  - test/haml/templates/silent_script.haml
138
137
  - test/haml/templates/very_basic.haml
138
+ - test/haml/templates/nuke_inner_whitespace.haml
139
139
  - test/haml/templates/eval_suppressed.haml
140
140
  - test/haml/templates/tag_parsing.haml
141
141
  - test/haml/templates/whitespace_handling.haml
@@ -149,14 +149,16 @@ files:
149
149
  - test/haml/templates/original_engine.haml
150
150
  - test/haml/templates/breakage.haml
151
151
  - test/haml/templates/action_view.haml
152
- - test/haml/runner.rb
152
+ - test/haml/test_helper.rb
153
153
  - test/haml/results
154
154
  - test/haml/results/content_for_layout.xhtml
155
155
  - test/haml/results/just_stuff.xhtml
156
156
  - test/haml/results/whitespace_handling.xhtml
157
+ - test/haml/results/nuke_outer_whitespace.xhtml
157
158
  - test/haml/results/silent_script.xhtml
158
159
  - test/haml/results/filters.xhtml
159
160
  - test/haml/results/standard.xhtml
161
+ - test/haml/results/nuke_inner_whitespace.xhtml
160
162
  - test/haml/results/helpful.xhtml
161
163
  - test/haml/results/very_basic.xhtml
162
164
  - test/haml/results/eval_suppressed.xhtml
@@ -168,40 +170,50 @@ files:
168
170
  - test/haml/markaby
169
171
  - test/haml/markaby/standard.mab
170
172
  - test/haml/engine_test.rb
171
- - test/profile.rb
172
173
  - test/benchmark.rb
173
174
  - Rakefile
174
175
  - init.rb
175
176
  - VERSION
176
177
  - 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
178
+ - README.rdoc
179
+ - FAQ
180
+ has_rdoc: true
181
+ homepage: http://haml.hamptoncatlin.com/
182
+ post_install_message:
185
183
  rdoc_options:
186
184
  - --title
187
185
  - Haml
188
186
  - --main
189
- - README
187
+ - README.rdoc
190
188
  - --exclude
191
189
  - lib/haml/buffer.rb
192
190
  - --line-numbers
193
191
  - --inline-source
194
- extra_rdoc_files:
195
- - VERSION
196
- - MIT-LICENSE
197
- - README
198
- executables:
199
- - haml
200
- - html2haml
201
- - sass
202
- extensions: []
203
-
192
+ require_paths:
193
+ - lib
194
+ required_ruby_version: !ruby/object:Gem::Requirement
195
+ requirements:
196
+ - - ">="
197
+ - !ruby/object:Gem::Version
198
+ version: "0"
199
+ version:
200
+ required_rubygems_version: !ruby/object:Gem::Requirement
201
+ requirements:
202
+ - - ">="
203
+ - !ruby/object:Gem::Version
204
+ version: "0"
205
+ version:
204
206
  requirements: []
205
207
 
206
- dependencies: []
207
-
208
+ rubyforge_project: haml
209
+ rubygems_version: 1.1.1
210
+ signing_key:
211
+ specification_version: 2
212
+ summary: An elegant, structured XHTML/XML templating engine. Comes with Sass, a similar CSS templating engine.
213
+ test_files:
214
+ - test/sass/plugin_test.rb
215
+ - test/sass/engine_test.rb
216
+ - test/haml/template_test.rb
217
+ - test/haml/html2haml_test.rb
218
+ - test/haml/helper_test.rb
219
+ - 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