mustache 0.99.1 → 0.99.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mustache/parser.rb +5 -5
- data/lib/mustache/version.rb +1 -1
- data/test/mustache_test.rb +14 -0
- metadata +4 -4
data/lib/mustache/parser.rb
CHANGED
@@ -139,6 +139,8 @@ EOF
|
|
139
139
|
error "Illegal content in tag" if content.empty?
|
140
140
|
|
141
141
|
fetch = [:mustache, :fetch, content.split('.')]
|
142
|
+
prev = @result
|
143
|
+
last_index = @result.size
|
142
144
|
|
143
145
|
# Based on the sigil, do what needs to be done.
|
144
146
|
case type
|
@@ -147,13 +149,11 @@ EOF
|
|
147
149
|
@result << [:mustache, :section, fetch, block]
|
148
150
|
@sections << [content, position, @result]
|
149
151
|
@result = block
|
150
|
-
last_index = 1
|
151
152
|
when '^'
|
152
153
|
block = [:multi]
|
153
154
|
@result << [:mustache, :inverted_section, fetch, block]
|
154
155
|
@sections << [content, position, @result]
|
155
156
|
@result = block
|
156
|
-
last_index = 1
|
157
157
|
when '/'
|
158
158
|
section, pos, result = @sections.pop
|
159
159
|
raw = @scanner.pre_match[pos[3]...pre_match_position] + padding
|
@@ -193,10 +193,10 @@ EOF
|
|
193
193
|
# the remaining whitespace. If not, but we've been hanging on to padding
|
194
194
|
# from the beginning of the line, re-insert the padding as static text.
|
195
195
|
if start_of_line
|
196
|
-
if @scanner.peek(
|
197
|
-
@scanner.skip(
|
196
|
+
if @scanner.peek(2) =~ /\r?\n/ && SKIP_WHITESPACE.include?(type)
|
197
|
+
@scanner.skip(/\r?\n/)
|
198
198
|
else
|
199
|
-
|
199
|
+
prev.insert(last_index, [:static, padding]) unless padding.empty?
|
200
200
|
end
|
201
201
|
end
|
202
202
|
|
data/lib/mustache/version.rb
CHANGED
data/test/mustache_test.rb
CHANGED
@@ -74,6 +74,20 @@ end_complex
|
|
74
74
|
assert_equal "\n full time\n", instance.render
|
75
75
|
end
|
76
76
|
|
77
|
+
def test_sassier_single_line_sections
|
78
|
+
instance = Mustache.new
|
79
|
+
instance.template = "\t{{#list}}\r\n\t{{/list}}"
|
80
|
+
|
81
|
+
assert_equal "", instance.render
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_padding_before_section
|
85
|
+
instance = Mustache.new
|
86
|
+
instance.template = "\t{{#list}}a{{/list}}"
|
87
|
+
|
88
|
+
assert_equal "\taa", instance.render(:list => [1, 2])
|
89
|
+
end
|
90
|
+
|
77
91
|
def test_two_line_sections
|
78
92
|
html = %(<p class="flash-notice" {{# no_flash }}style="display: none;"\n{{/ no_flash }}>)
|
79
93
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mustache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 407
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 99
|
9
|
-
-
|
10
|
-
version: 0.99.
|
9
|
+
- 2
|
10
|
+
version: 0.99.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Chris Wanstrath
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2011-03-
|
20
|
+
date: 2011-03-06 00:00:00 -08:00
|
21
21
|
default_executable:
|
22
22
|
dependencies: []
|
23
23
|
|