haml 2.0.4 → 2.0.5
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of haml might be problematic. Click here for more details.
- data/README.rdoc +3 -3
- data/VERSION +1 -1
- data/lib/haml.rb +1 -1
- data/lib/haml/helpers.rb +10 -2
- data/lib/haml/helpers/action_view_mods.rb +10 -12
- data/lib/haml/html.rb +0 -1
- data/lib/haml/precompiler.rb +5 -1
- data/lib/sass.rb +1 -1
- data/lib/sass/css.rb +1 -1
- data/test/haml/engine_test.rb +8 -8
- data/test/haml/helper_test.rb +13 -1
- data/test/haml/template_test.rb +6 -2
- data/test/haml/templates/helpers.haml +37 -14
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -31,12 +31,12 @@ to corresponding CSS files in public/stylesheets when needed
|
|
31
31
|
see the Sass module docs for details).
|
32
32
|
|
33
33
|
For Merb, <tt>.html.haml</tt> views will work without any further modification.
|
34
|
-
To enable Sass, you also need to add
|
34
|
+
To enable Sass, you also need to add a dependency.
|
35
35
|
To do so, just add
|
36
36
|
|
37
|
-
dependency "haml"
|
37
|
+
dependency "merb-haml"
|
38
38
|
|
39
|
-
to config/dependencies.rb.
|
39
|
+
to config/dependencies.rb (or config/init.rb in a flat/very flat Merb application).
|
40
40
|
Then it'll work just like it does in Rails.
|
41
41
|
|
42
42
|
To use Haml and Sass programatically,
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.
|
1
|
+
2.0.5
|
data/lib/haml.rb
CHANGED
@@ -39,7 +39,7 @@ $LOAD_PATH.unshift dir unless $LOAD_PATH.include?(dir)
|
|
39
39
|
# Once it's installed, all view files with the ".html.haml" extension
|
40
40
|
# will be compiled using Haml.
|
41
41
|
#
|
42
|
-
# To run Haml from the
|
42
|
+
# To run Haml from the command line, just use
|
43
43
|
#
|
44
44
|
# haml input.haml output.html
|
45
45
|
#
|
data/lib/haml/helpers.rb
CHANGED
@@ -54,9 +54,9 @@ module Haml
|
|
54
54
|
def non_haml
|
55
55
|
was_active = @haml_buffer.active?
|
56
56
|
@haml_buffer.active = false
|
57
|
-
|
57
|
+
yield
|
58
|
+
ensure
|
58
59
|
@haml_buffer.active = was_active
|
59
|
-
res
|
60
60
|
end
|
61
61
|
|
62
62
|
# call-seq:
|
@@ -405,6 +405,14 @@ END
|
|
405
405
|
!@haml_buffer.nil? && @haml_buffer.active?
|
406
406
|
end
|
407
407
|
|
408
|
+
# Returns whether or not +block+ is defined directly in a Haml template.
|
409
|
+
def block_is_haml?(block)
|
410
|
+
eval('_hamlout', block)
|
411
|
+
true
|
412
|
+
rescue
|
413
|
+
false
|
414
|
+
end
|
415
|
+
|
408
416
|
private
|
409
417
|
|
410
418
|
# call-seq:
|
@@ -51,15 +51,8 @@ if defined?(ActionView) and not defined?(Merb::Plugins)
|
|
51
51
|
# if it's not actually in the template context,
|
52
52
|
# as detected by the existance of an _erbout variable.
|
53
53
|
# We've got to do the same thing for compatibility.
|
54
|
-
block_is_haml =
|
55
|
-
begin
|
56
|
-
eval('_hamlout', block)
|
57
|
-
true
|
58
|
-
rescue
|
59
|
-
false
|
60
|
-
end
|
61
54
|
|
62
|
-
if
|
55
|
+
if is_haml? && block_is_haml?(block)
|
63
56
|
capture_haml(*args, &block)
|
64
57
|
else
|
65
58
|
capture_without_haml(*args, &block)
|
@@ -106,14 +99,19 @@ if defined?(ActionView) and not defined?(Merb::Plugins)
|
|
106
99
|
|
107
100
|
module TagHelper
|
108
101
|
def content_tag_with_haml(name, *args, &block)
|
109
|
-
|
102
|
+
return content_tag_without_haml(name, *args, &block) unless is_haml?
|
103
|
+
|
104
|
+
preserve = haml_buffer.options[:preserve].include?(name.to_s)
|
110
105
|
|
111
|
-
if
|
112
|
-
|
106
|
+
if block_given? && block_is_haml?(block) && preserve
|
107
|
+
return content_tag_without_haml(name, *args) {preserve(&block)}
|
113
108
|
end
|
114
109
|
|
115
|
-
content
|
110
|
+
returning content_tag_without_haml(name, *args, &block) do |content|
|
111
|
+
return Haml::Helpers.preserve(content) if preserve && content
|
112
|
+
end
|
116
113
|
end
|
114
|
+
|
117
115
|
alias_method :content_tag_without_haml, :content_tag
|
118
116
|
alias_method :content_tag, :content_tag_with_haml
|
119
117
|
end
|
data/lib/haml/html.rb
CHANGED
data/lib/haml/precompiler.rb
CHANGED
@@ -93,6 +93,7 @@ module Haml
|
|
93
93
|
extend Haml::Helpers
|
94
94
|
_hamlout = @haml_buffer = Haml::Buffer.new(@haml_buffer, #{options_for_buffer.inspect})
|
95
95
|
_erbout = _hamlout.buffer
|
96
|
+
__in_erb_template = true
|
96
97
|
END
|
97
98
|
postamble = <<END.gsub("\n", ";")
|
98
99
|
@haml_buffer = @haml_buffer.upper
|
@@ -105,7 +106,10 @@ END
|
|
105
106
|
names = names.keys if Hash == names
|
106
107
|
|
107
108
|
names.map do |name|
|
108
|
-
|
109
|
+
# Can't use || because someone might explicitly pass in false with a symbol
|
110
|
+
sym_local = "_haml_locals[#{name.to_sym.inspect}]"
|
111
|
+
str_local = "_haml_locals[#{name.to_s.inspect}]"
|
112
|
+
"#{name} = #{sym_local}.nil? ? #{str_local} : #{sym_local}"
|
109
113
|
end.join(';') + ';'
|
110
114
|
end
|
111
115
|
|
data/lib/sass.rb
CHANGED
@@ -51,7 +51,7 @@ $LOAD_PATH.unshift dir unless $LOAD_PATH.include?(dir)
|
|
51
51
|
# Then, whenever necessary, they're compiled into corresponding CSS files in public/stylesheets.
|
52
52
|
# For instance, public/stylesheets/sass/main.sass would be compiled to public/stylesheets/main.css.
|
53
53
|
#
|
54
|
-
# To run Sass from the
|
54
|
+
# To run Sass from the command line, just use
|
55
55
|
#
|
56
56
|
# sass input.sass output.css
|
57
57
|
#
|
data/lib/sass/css.rb
CHANGED
@@ -237,7 +237,7 @@ module Sass
|
|
237
237
|
root.children.map! do |child|
|
238
238
|
next child unless Tree::RuleNode === child && child.rule.include?(',')
|
239
239
|
child.rule.split(',').map do |rule|
|
240
|
-
node = Tree::RuleNode.new(rule.strip,
|
240
|
+
node = Tree::RuleNode.new(rule.strip, {})
|
241
241
|
node.children = child.children
|
242
242
|
node
|
243
243
|
end
|
data/test/haml/engine_test.rb
CHANGED
@@ -275,23 +275,23 @@ HAML
|
|
275
275
|
end
|
276
276
|
|
277
277
|
def test_escaped_inline_string_interpolation
|
278
|
-
assert_equal("<p>4&3</p>\n", render("%p&==
|
279
|
-
assert_equal("<p>4&3</p>\n", render("%p&==
|
278
|
+
assert_equal("<p>4&3</p>\n", render("%p&== \#{2+2}&\#{2+1}", :escape_html => true))
|
279
|
+
assert_equal("<p>4&3</p>\n", render("%p&== \#{2+2}&\#{2+1}", :escape_html => false))
|
280
280
|
end
|
281
281
|
|
282
282
|
def test_unescaped_inline_string_interpolation
|
283
|
-
assert_equal("<p>4&3</p>\n", render("%p!==
|
284
|
-
assert_equal("<p>4&3</p>\n", render("%p!==
|
283
|
+
assert_equal("<p>4&3</p>\n", render("%p!== \#{2+2}&\#{2+1}", :escape_html => true))
|
284
|
+
assert_equal("<p>4&3</p>\n", render("%p!== \#{2+2}&\#{2+1}", :escape_html => false))
|
285
285
|
end
|
286
286
|
|
287
287
|
def test_escaped_string_interpolation
|
288
|
-
assert_equal("<p>\n 4&3\n</p>\n", render("%p\n &==
|
289
|
-
assert_equal("<p>\n 4&3\n</p>\n", render("%p\n &==
|
288
|
+
assert_equal("<p>\n 4&3\n</p>\n", render("%p\n &== \#{2+2}&\#{2+1}", :escape_html => true))
|
289
|
+
assert_equal("<p>\n 4&3\n</p>\n", render("%p\n &== \#{2+2}&\#{2+1}", :escape_html => false))
|
290
290
|
end
|
291
291
|
|
292
292
|
def test_unescaped_string_interpolation
|
293
|
-
assert_equal("<p>\n 4&3\n</p>\n", render("%p\n !==
|
294
|
-
assert_equal("<p>\n 4&3\n</p>\n", render("%p\n !==
|
293
|
+
assert_equal("<p>\n 4&3\n</p>\n", render("%p\n !== \#{2+2}&\#{2+1}", :escape_html => true))
|
294
|
+
assert_equal("<p>\n 4&3\n</p>\n", render("%p\n !== \#{2+2}&\#{2+1}", :escape_html => false))
|
295
295
|
end
|
296
296
|
|
297
297
|
def test_scripts_should_respect_escape_html_option
|
data/test/haml/helper_test.rb
CHANGED
@@ -95,7 +95,19 @@ class HelperTest < Test::Unit::TestCase
|
|
95
95
|
def test_capture_haml
|
96
96
|
assert_equal("\"<p>13</p>\\n\"\n", render("- foo = capture_haml(13) do |a|\n %p= a\n= foo.dump"))
|
97
97
|
end
|
98
|
-
|
98
|
+
|
99
|
+
def test_content_tag_block
|
100
|
+
assert_equal(<<HTML.strip, render(<<HAML, :action_view))
|
101
|
+
<div><p>bar</p>
|
102
|
+
<strong>bar</strong>
|
103
|
+
</div>
|
104
|
+
HTML
|
105
|
+
- content_tag :div do
|
106
|
+
%p bar
|
107
|
+
%strong bar
|
108
|
+
HAML
|
109
|
+
end
|
110
|
+
|
99
111
|
def test_haml_tag_attribute_html_escaping
|
100
112
|
assert_equal("<p id='foo&bar'>baz</p>\n", render("%p{:id => 'foo&bar'} baz", :escape_html => true))
|
101
113
|
end
|
data/test/haml/template_test.rb
CHANGED
@@ -4,6 +4,8 @@ require 'haml/template'
|
|
4
4
|
require 'sass/plugin'
|
5
5
|
require File.dirname(__FILE__) + '/mocks/article'
|
6
6
|
|
7
|
+
require 'action_pack/version'
|
8
|
+
|
7
9
|
module Haml::Filters::Test
|
8
10
|
include Haml::Filters::Base
|
9
11
|
|
@@ -28,8 +30,10 @@ class TemplateTest < Test::Unit::TestCase
|
|
28
30
|
TEMPLATE_PATH = File.join(File.dirname(__FILE__), "templates")
|
29
31
|
TEMPLATES = %w{ very_basic standard helpers
|
30
32
|
whitespace_handling original_engine list helpful
|
31
|
-
silent_script tag_parsing just_stuff partials
|
33
|
+
silent_script tag_parsing just_stuff partials
|
32
34
|
filters nuke_outer_whitespace nuke_inner_whitespace }
|
35
|
+
# partial layouts were introduced in 2.0.0
|
36
|
+
TEMPLATES << 'partial_layout' unless ActionPack::VERSION::MAJOR < 2
|
33
37
|
|
34
38
|
def setup
|
35
39
|
vars = { 'article' => Article.new, 'foo' => 'value one' }
|
@@ -70,7 +74,7 @@ class TemplateTest < Test::Unit::TestCase
|
|
70
74
|
end
|
71
75
|
|
72
76
|
def assert_renders_correctly(name, &render_method)
|
73
|
-
render_method ||= proc { |name| @base.render(name) }
|
77
|
+
render_method ||= proc { |name| @base.render(:file => name) }
|
74
78
|
|
75
79
|
load_result(name).split("\n").zip(render_method[name].split("\n")).each_with_index do |pair, line|
|
76
80
|
message = "template: #{name}\nline: #{line}"
|
@@ -35,20 +35,43 @@ click
|
|
35
35
|
%p boom
|
36
36
|
- concat "foo\n"
|
37
37
|
- haml_buffer.tabulation = 0
|
38
|
-
|
39
|
-
-#
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
38
|
+
-#
|
39
|
+
-# ActionPack pre-2.0 has weird url_for issues here.
|
40
|
+
- if ActionPack::VERSION::MAJOR < 2
|
41
|
+
:plain
|
42
|
+
<p>
|
43
|
+
<form action="" method="post">
|
44
|
+
</p>
|
45
|
+
<form action="" method="post">
|
46
|
+
<div><input name="commit" type="submit" value="save" /></div>
|
47
|
+
<p>
|
48
|
+
@foo =
|
49
|
+
value one
|
50
|
+
</p>
|
51
|
+
Toplevel? false
|
52
|
+
<p>
|
53
|
+
@foo =
|
54
|
+
value three
|
55
|
+
</p>
|
56
|
+
</form>
|
57
|
+
<form action="" method="post">
|
58
|
+
Title:
|
59
|
+
<input id="article_title" name="article[title]" size="30" type="text" value="Hello" />
|
60
|
+
Body:
|
61
|
+
<input id="article_body" name="article[body]" size="30" type="text" value="World" />
|
62
|
+
</form>
|
63
|
+
- else
|
64
|
+
%p
|
65
|
+
= form_tag ''
|
66
|
+
- form_tag '' do
|
67
|
+
%div= submit_tag 'save'
|
68
|
+
- @foo = 'value one'
|
69
|
+
= test_partial 'partial'
|
70
|
+
- form_for :article, @article, :url => '' do |f|
|
71
|
+
Title:
|
72
|
+
= f.text_field :title
|
73
|
+
Body:
|
74
|
+
= f.text_field :body
|
52
75
|
= list_of({:google => 'http://www.google.com'}) do |name, link|
|
53
76
|
%a{ :href => link }= name
|
54
77
|
%p
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: haml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Weizenbaum
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2008-
|
13
|
+
date: 2008-11-28 00:00:00 -08:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|