haml 1.8.0 → 1.8.1
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/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/haml.rb +1 -1
- data/lib/haml/buffer.rb +5 -1
- data/lib/haml/precompiler.rb +1 -1
- data/lib/haml/template/plugin.rb +12 -0
- data/lib/sass/plugin/merb.rb +13 -4
- data/lib/sass/plugin/rails.rb +5 -3
- data/test/haml/engine_test.rb +21 -0
- metadata +3 -2
data/Rakefile
CHANGED
@@ -71,7 +71,7 @@ unless ARGV[0] == 'benchmark'
|
|
71
71
|
list.exclude(/[a-z]/)
|
72
72
|
list.exclude('TODO')
|
73
73
|
end.to_a
|
74
|
-
spec.executables = ['haml', 'html2haml', 'sass']
|
74
|
+
spec.executables = ['haml', 'html2haml', 'sass', 'css2sass']
|
75
75
|
spec.files = FileList['lib/**/*', 'bin/*', 'test/**/*', 'Rakefile', 'init.rb'].to_a + readmes
|
76
76
|
spec.autorequire = ['haml', 'sass']
|
77
77
|
spec.homepage = 'http://haml.hamptoncatlin.com/'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.8.
|
1
|
+
1.8.1
|
data/lib/haml.rb
CHANGED
@@ -750,7 +750,7 @@ $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
|
|
750
750
|
#
|
751
751
|
# [<tt>:autoclose</tt>] A list of tag names that should be automatically self-closed
|
752
752
|
# if they have no content.
|
753
|
-
# Defaults to <tt>['meta', 'img', 'link', '
|
753
|
+
# Defaults to <tt>['meta', 'img', 'link', 'br', 'hr', 'input', 'area']</tt>.
|
754
754
|
#
|
755
755
|
module Haml
|
756
756
|
# This method is called by init.rb,
|
data/lib/haml/buffer.rb
CHANGED
@@ -115,7 +115,7 @@ module Haml
|
|
115
115
|
else
|
116
116
|
@buffer << "\n#{tabs(@real_tabs+1)}#{content}\n#{tabs(@real_tabs)}</#{name}>\n"
|
117
117
|
end
|
118
|
-
|
118
|
+
elsif !atomic
|
119
119
|
@real_tabs += 1
|
120
120
|
end
|
121
121
|
end
|
@@ -123,11 +123,15 @@ module Haml
|
|
123
123
|
def self.merge_attrs(to, from)
|
124
124
|
if to['id'] && from['id']
|
125
125
|
to['id'] << '_' << from.delete('id')
|
126
|
+
elsif to['id'] || from['id']
|
127
|
+
from['id'] ||= to['id']
|
126
128
|
end
|
127
129
|
|
128
130
|
if to['class'] && from['class']
|
129
131
|
# Make sure we don't duplicate class names
|
130
132
|
from['class'] = (from['class'].split(' ') | to['class'].split(' ')).join(' ')
|
133
|
+
elsif to['class'] || from['class']
|
134
|
+
from['class'] ||= to['class']
|
131
135
|
end
|
132
136
|
|
133
137
|
to.merge!(from)
|
data/lib/haml/precompiler.rb
CHANGED
@@ -122,7 +122,7 @@ END
|
|
122
122
|
@tab_change = 0
|
123
123
|
|
124
124
|
old_line = Line.new
|
125
|
-
(@template + "\n-#").split("\n").each_with_index do |text, index|
|
125
|
+
(@template + "\n-#\n-#").split("\n").each_with_index do |text, index|
|
126
126
|
line = Line.new text.strip, text.lstrip.chomp, index
|
127
127
|
line.spaces, line.tabs = count_soft_tabs(text)
|
128
128
|
|
data/lib/haml/template/plugin.rb
CHANGED
@@ -1,12 +1,23 @@
|
|
1
|
+
# :stopdoc:
|
1
2
|
# This file makes Haml work with Rails
|
2
3
|
# using the > 2.0.1 template handler API.
|
3
4
|
|
4
5
|
module Haml
|
5
6
|
class Template
|
7
|
+
include ActionView::TemplateHandlers::Compilable if defined?(ActionView::TemplateHandlers::Compilable)
|
8
|
+
|
6
9
|
def self.line_offset
|
7
10
|
1
|
8
11
|
end
|
9
12
|
|
13
|
+
def compilable?
|
14
|
+
true
|
15
|
+
end
|
16
|
+
|
17
|
+
def line_offset
|
18
|
+
self.class.line_offset
|
19
|
+
end
|
20
|
+
|
10
21
|
def initialize(view)
|
11
22
|
@view = view
|
12
23
|
end
|
@@ -19,3 +30,4 @@ module Haml
|
|
19
30
|
end
|
20
31
|
|
21
32
|
ActionView::Base.register_template_handler(:haml, Haml::Template)
|
33
|
+
# :startdoc:
|
data/lib/sass/plugin/merb.rb
CHANGED
@@ -1,10 +1,19 @@
|
|
1
1
|
unless defined?(Sass::MERB_LOADED)
|
2
2
|
Sass::MERB_LOADED = true
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
version = Merb::VERSION.split('.').map { |n| n.to_i }
|
5
|
+
if version[0] <= 0 && version[1] < 5
|
6
|
+
root = MERB_ROOT
|
7
|
+
env = MERB_ENV
|
8
|
+
else
|
9
|
+
root = Merb.root
|
10
|
+
env = Merb.environment
|
11
|
+
end
|
12
|
+
|
13
|
+
Sass::Plugin.options.merge!(:template_location => root + '/public/stylesheets/sass',
|
14
|
+
:css_location => root + '/public/stylesheets',
|
15
|
+
:always_check => env != "production",
|
16
|
+
:full_exception => env != "production")
|
8
17
|
config = Merb::Plugins.config[:sass] || Merb::Plugins.config["sass"] || {}
|
9
18
|
config.symbolize_keys!
|
10
19
|
Sass::Plugin.options.merge!(config)
|
data/lib/sass/plugin/rails.rb
CHANGED
@@ -5,9 +5,10 @@ unless defined?(Sass::RAILS_LOADED)
|
|
5
5
|
:css_location => RAILS_ROOT + '/public/stylesheets',
|
6
6
|
:always_check => RAILS_ENV != "production",
|
7
7
|
:full_exception => RAILS_ENV != "production")
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
|
9
|
+
# :stopdoc:
|
10
|
+
module ActionController
|
11
|
+
class Base
|
11
12
|
alias_method :sass_old_process, :process
|
12
13
|
def process(*args)
|
13
14
|
Sass::Plugin.update_stylesheets if Sass::Plugin.options[:always_update] || Sass::Plugin.options[:always_check]
|
@@ -15,4 +16,5 @@ unless defined?(Sass::RAILS_LOADED)
|
|
15
16
|
end
|
16
17
|
end
|
17
18
|
end
|
19
|
+
# :startdoc:
|
18
20
|
end
|
data/test/haml/engine_test.rb
CHANGED
@@ -93,6 +93,10 @@ class EngineTest < Test::Unit::TestCase
|
|
93
93
|
assert_equal("<img alt='' src='/foo.png' />\n", render("%img{:width => nil, :src => '/foo.png', :alt => String.new}"))
|
94
94
|
end
|
95
95
|
|
96
|
+
def test_end_of_file_multiline
|
97
|
+
assert_equal("<p>0</p>\n<p>1</p>\n<p>2</p>\n", render("- for i in (0...3)\n %p= |\n i |"))
|
98
|
+
end
|
99
|
+
|
96
100
|
# Options tests
|
97
101
|
|
98
102
|
def test_stop_eval
|
@@ -135,6 +139,19 @@ class EngineTest < Test::Unit::TestCase
|
|
135
139
|
assert_equal("<p>nil</p>\n", render("%p{ :attr => x } nil", :locals => {:x => nil}))
|
136
140
|
end
|
137
141
|
|
142
|
+
def test_nil_id_with_syntactic_id
|
143
|
+
assert_equal("<p id='foo'>nil</p>\n", render("%p#foo{:id => nil} nil"))
|
144
|
+
assert_equal("<p id='foo_bar'>nil</p>\n", render("%p#foo{{:id => 'bar'}, :id => nil} nil"))
|
145
|
+
assert_equal("<p id='foo_bar'>nil</p>\n", render("%p#foo{{:id => nil}, :id => 'bar'} nil"))
|
146
|
+
end
|
147
|
+
|
148
|
+
def test_nil_class_with_syntactic_class
|
149
|
+
assert_equal("<p class='foo'>nil</p>\n", render("%p.foo{:class => nil} nil"))
|
150
|
+
assert_equal("<p class='bar foo'>nil</p>\n", render("%p.bar.foo{:class => nil} nil"))
|
151
|
+
assert_equal("<p class='bar foo'>nil</p>\n", render("%p.foo{{:class => 'bar'}, :class => nil} nil"))
|
152
|
+
assert_equal("<p class='bar foo'>nil</p>\n", render("%p.foo{{:class => nil}, :class => 'bar'} nil"))
|
153
|
+
end
|
154
|
+
|
138
155
|
def test_locals
|
139
156
|
assert_equal("<p>Paragraph!</p>\n", render("%p= text", :locals => { :text => "Paragraph!" }))
|
140
157
|
end
|
@@ -156,6 +173,10 @@ class EngineTest < Test::Unit::TestCase
|
|
156
173
|
assert_equal("<p a='b2c'>\n</p>\n", render("%p{:a => 'b' + (1 + 1).to_s + 'c'}"))
|
157
174
|
end
|
158
175
|
|
176
|
+
def test_dynamic_attrs_with_self_closed_tag
|
177
|
+
assert_equal("<a b='2' />\nc\n", render("%a{'b' => 1 + 1}/\n= 'c'\n"))
|
178
|
+
end
|
179
|
+
|
159
180
|
def test_rec_merge
|
160
181
|
hash1 = {1=>2, 3=>{5=>7, 8=>9}}
|
161
182
|
hash2 = {4=>5, 3=>{5=>2, 16=>12}}
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: haml
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.8.
|
7
|
-
date: 2008-01-
|
6
|
+
version: 1.8.1
|
7
|
+
date: 2008-01-28 00:00:00 -08:00
|
8
8
|
summary: An elegant, structured XHTML/XML templating engine. Comes with Sass, a similar CSS templating engine.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -199,6 +199,7 @@ executables:
|
|
199
199
|
- haml
|
200
200
|
- html2haml
|
201
201
|
- sass
|
202
|
+
- css2sass
|
202
203
|
extensions: []
|
203
204
|
|
204
205
|
requirements: []
|