haml-edge 2.3.11 → 2.3.12
Sign up to get free protection for your applications and to get access to all the features.
- data/EDGE_GEM_VERSION +1 -1
- data/VERSION +1 -1
- data/lib/haml/html.rb +64 -45
- data/lib/haml/precompiler.rb +4 -1
- data/lib/sass/script/funcall.rb +1 -1
- data/test/haml/template_test.rb +4 -2
- data/test/test_helper.rb +1 -1
- metadata +2 -2
data/EDGE_GEM_VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.3.
|
1
|
+
2.3.12
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.3.
|
1
|
+
2.3.12
|
data/lib/haml/html.rb
CHANGED
@@ -2,9 +2,60 @@ require File.dirname(__FILE__) + '/../haml'
|
|
2
2
|
|
3
3
|
require 'haml/engine'
|
4
4
|
require 'rubygems'
|
5
|
-
require 'hpricot'
|
6
5
|
require 'cgi'
|
7
6
|
|
7
|
+
module Haml
|
8
|
+
class HTML
|
9
|
+
# A module containing utility methods that every Hpricot node
|
10
|
+
# should have.
|
11
|
+
module Node
|
12
|
+
# Returns the Haml representation of the given node.
|
13
|
+
#
|
14
|
+
# @param tabs [Fixnum] The indentation level of the resulting Haml.
|
15
|
+
# @option options (see Haml::HTML#initialize)
|
16
|
+
def to_haml(tabs, options)
|
17
|
+
parse_text(self.to_s, tabs)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def tabulate(tabs)
|
23
|
+
' ' * tabs
|
24
|
+
end
|
25
|
+
|
26
|
+
def parse_text(text, tabs)
|
27
|
+
text.strip!
|
28
|
+
if text.empty?
|
29
|
+
String.new
|
30
|
+
else
|
31
|
+
lines = text.split("\n")
|
32
|
+
|
33
|
+
lines.map do |line|
|
34
|
+
line.strip!
|
35
|
+
"#{tabulate(tabs)}#{'\\' if Haml::Engine::SPECIAL_CHARACTERS.include?(line[0])}#{line}\n"
|
36
|
+
end.join
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# Haml monkeypatches various Hpricot classes
|
44
|
+
# to add methods for conversion to Haml.
|
45
|
+
module Hpricot
|
46
|
+
# @see Hpricot
|
47
|
+
module Node
|
48
|
+
include Haml::HTML::Node
|
49
|
+
end
|
50
|
+
|
51
|
+
# @see Hpricot
|
52
|
+
class BaseEle
|
53
|
+
include Haml::HTML::Node
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
require 'hpricot'
|
58
|
+
|
8
59
|
module Haml
|
9
60
|
# Converts HTML documents into Haml templates.
|
10
61
|
# Depends on [Hpricot](http://code.whytheluckystiff.net/hpricot/) for HTML parsing.
|
@@ -46,67 +97,35 @@ module Haml
|
|
46
97
|
end
|
47
98
|
alias_method :to_haml, :render
|
48
99
|
|
49
|
-
# Haml monkeypatches various Hpricot classes
|
50
|
-
# to add methods for conversion to Haml.
|
51
|
-
module ::Hpricot::Node
|
52
|
-
# Returns the Haml representation of the given node.
|
53
|
-
#
|
54
|
-
# @param tabs [Fixnum] The indentation level of the resulting Haml.
|
55
|
-
# @option options (see Haml::HTML#initialize)
|
56
|
-
def to_haml(tabs, options)
|
57
|
-
parse_text(self.to_s, tabs)
|
58
|
-
end
|
59
|
-
|
60
|
-
private
|
61
|
-
|
62
|
-
def tabulate(tabs)
|
63
|
-
' ' * tabs
|
64
|
-
end
|
65
|
-
|
66
|
-
def parse_text(text, tabs)
|
67
|
-
text.strip!
|
68
|
-
if text.empty?
|
69
|
-
String.new
|
70
|
-
else
|
71
|
-
lines = text.split("\n")
|
72
|
-
|
73
|
-
lines.map do |line|
|
74
|
-
line.strip!
|
75
|
-
"#{tabulate(tabs)}#{'\\' if Haml::Engine::SPECIAL_CHARACTERS.include?(line[0])}#{line}\n"
|
76
|
-
end.join
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
100
|
TEXT_REGEXP = /^(\s*).*$/
|
82
101
|
|
83
|
-
# @see Hpricot
|
102
|
+
# @see Hpricot
|
84
103
|
class ::Hpricot::Doc
|
85
|
-
# @see
|
104
|
+
# @see Haml::HTML::Node#to_haml
|
86
105
|
def to_haml(tabs, options)
|
87
106
|
(children || []).inject('') {|s, c| s << c.to_haml(0, options)}
|
88
107
|
end
|
89
108
|
end
|
90
109
|
|
91
|
-
# @see Hpricot
|
110
|
+
# @see Hpricot
|
92
111
|
class ::Hpricot::XMLDecl
|
93
|
-
# @see
|
112
|
+
# @see Haml::HTML::Node#to_haml
|
94
113
|
def to_haml(tabs, options)
|
95
114
|
"#{tabulate(tabs)}!!! XML\n"
|
96
115
|
end
|
97
116
|
end
|
98
117
|
|
99
|
-
# @see Hpricot
|
118
|
+
# @see Hpricot
|
100
119
|
class ::Hpricot::CData
|
101
|
-
# @see
|
120
|
+
# @see Haml::HTML::Node#to_haml
|
102
121
|
def to_haml(tabs, options)
|
103
122
|
"#{tabulate(tabs)}:cdata\n#{parse_text(self.content, tabs + 1)}"
|
104
123
|
end
|
105
124
|
end
|
106
125
|
|
107
|
-
# @see Hpricot
|
126
|
+
# @see Hpricot
|
108
127
|
class ::Hpricot::DocType
|
109
|
-
# @see
|
128
|
+
# @see Haml::HTML::Node#to_haml
|
110
129
|
def to_haml(tabs, options)
|
111
130
|
attrs = public_id.scan(/DTD\s+([^\s]+)\s*([^\s]*)\s*([^\s]*)\s*\/\//)[0]
|
112
131
|
if attrs == nil
|
@@ -137,17 +156,17 @@ module Haml
|
|
137
156
|
end
|
138
157
|
end
|
139
158
|
|
140
|
-
# @see Hpricot
|
159
|
+
# @see Hpricot
|
141
160
|
class ::Hpricot::Comment
|
142
|
-
# @see
|
161
|
+
# @see Haml::HTML::Node#to_haml
|
143
162
|
def to_haml(tabs, options)
|
144
163
|
"#{tabulate(tabs)}/\n#{parse_text(self.content, tabs + 1)}"
|
145
164
|
end
|
146
165
|
end
|
147
166
|
|
148
|
-
# @see Hpricot
|
167
|
+
# @see Hpricot
|
149
168
|
class ::Hpricot::Elem
|
150
|
-
# @see
|
169
|
+
# @see Haml::HTML::Node#to_haml
|
151
170
|
def to_haml(tabs, options)
|
152
171
|
output = "#{tabulate(tabs)}"
|
153
172
|
if options[:rhtml] && name[0...5] == 'haml:'
|
data/lib/haml/precompiler.rb
CHANGED
@@ -571,7 +571,10 @@ END
|
|
571
571
|
attributes = {}
|
572
572
|
|
573
573
|
scanner.scan(/\(\s*/)
|
574
|
-
|
574
|
+
loop do
|
575
|
+
name, value = parse_new_attribute(scanner)
|
576
|
+
break if name.nil?
|
577
|
+
|
575
578
|
if name == false
|
576
579
|
text = (Haml::Shared.balance(line, ?(, ?)) || [line]).first
|
577
580
|
raise Haml::SyntaxError.new("Invalid attribute list: #{text.inspect}.", last_line - 1)
|
data/lib/sass/script/funcall.rb
CHANGED
@@ -42,7 +42,7 @@ module Sass
|
|
42
42
|
|
43
43
|
return Functions::EvaluationContext.new(environment.options).send(name, *args)
|
44
44
|
rescue ArgumentError => e
|
45
|
-
raise e unless e.backtrace.first =~ /:in `(#{name}|perform)'$/
|
45
|
+
raise e unless e.backtrace.first =~ /:in `(block in )?(#{name}|perform)'$/
|
46
46
|
raise Sass::SyntaxError.new("#{e.message} for `#{name}'")
|
47
47
|
end
|
48
48
|
end
|
data/test/haml/template_test.rb
CHANGED
@@ -140,8 +140,10 @@ class TemplateTest < Test::Unit::TestCase
|
|
140
140
|
end
|
141
141
|
|
142
142
|
def test_action_view_templates_render_correctly
|
143
|
-
@base.
|
144
|
-
|
143
|
+
@base.with_output_buffer("") do
|
144
|
+
@base.content_for(:layout) {'Lorem ipsum dolor sit amet'}
|
145
|
+
assert_renders_correctly 'content_for_layout'
|
146
|
+
end
|
145
147
|
end
|
146
148
|
|
147
149
|
def test_instance_variables_should_work_inside_templates
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: haml-edge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.12
|
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: 2009-07-
|
13
|
+
date: 2009-07-14 00:00:00 -04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|