fixed haml filter.

This commit is contained in:
mattn
2010-03-09 01:31:14 +09:00
parent 4c34110628
commit e22429aba9
2 changed files with 22 additions and 20 deletions

View File

@@ -295,10 +295,10 @@ finish
'category': 'haml',
'tests': [
{
'name': "ul#foo>li.bar$[foo=bar][bar=baz]*3>{baz}+br",
'query': "ul#foo>li.bar$[foo=bar][bar=baz]*3>{baz}+br",
'name': "div>p+ul#foo>li.bar$[foo=bar][bar=baz]*3>{baz}",
'query': "div>p+ul#foo>li.bar$[foo=bar][bar=baz]*3>{baz}",
'type': "haml",
'result': "%ul#foo\n %li.bar1{ :foo => \"bar\", :bar => \"baz\" } baz\n %br/\n %li.bar2{ :foo => \"bar\", :bar => \"baz\" } baz\n %br/\n %li.bar3{ :foo => \"bar\", :bar => \"baz\" } baz\n %br/\n",
'result': "%div\n %p<\n %ul#foo\n %li.bar1{ :foo => \"bar\", :bar => \"baz\" } baz\n %li.bar2{ :foo => \"bar\", :bar => \"baz\" } baz\n %li.bar3{ :foo => \"bar\", :bar => \"baz\" } baz\n",
},
],
},

View File

@@ -1131,27 +1131,29 @@ function! s:zen_toString(...)
let str .= '{' . tmp . ' }'
endif
if stridx(','.s:zen_settings['html'].empty_elements.',', ','.current.name.',') != -1
let str .= "/\n"
let str .= "/"
elseif stridx(','.s:zen_settings['html'].block_elements.',', ','.current.name.',') != -1 && len(current.child) == 0
let str .= '<'
endif
endif
if len(current.value) > 0
let lines = split(current.value[1:-2], "\n")
let inner = ''
if len(current.child) == 1 && len(current.child[0].name) == 0
"let str .= s:zen_toString(current.child[0], type, inline, filter)
let lines = split(current.child[0].value[1:-2], "\n")
let str .= " " . lines[0]
for line in lines[1:]
let str .= " |\n" . line
endfor
endif
let inner = ''
elseif len(current.child) > 0
for child in current.child
let inner .= s:zen_toString(child, type, inline, filter)
if len(child.name) == 0
let inner .= "\n"
endif
endfor
let inner = substitute(inner, "\n", "\n ", 'g')
let str .= substitute(inner, " $", "", 'g')
let inner = substitute(inner, "\n $", "", 'g')
let str .= "\n " . inner
endif
endif
let str .= "\n"
else
if len(current.snippet) > 0
let tmp = substitute(current.snippet, '|', '${cursor}', 'g')