Fixed #98 pass to indent to html#toString()

This commit is contained in:
mattn
2013-04-24 20:43:15 +09:00
parent 7c1f881014
commit 6fd2031fa2
4 changed files with 16 additions and 10 deletions

View File

@@ -1,7 +1,7 @@
"============================================================================= "=============================================================================
" zencoding.vim " zencoding.vim
" Author: Yasuhiro Matsumoto <mattn.jp@gmail.com> " Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
" Last Change: 23-Apr-2013. " Last Change: 24-Apr-2013.
let s:save_cpo = &cpo let s:save_cpo = &cpo
set cpo&vim set cpo&vim
@@ -157,9 +157,13 @@ function! zencoding#toString(...)
else else
let group_itemno = 0 let group_itemno = 0
endif endif
if a:0 > 5
let indent = a:6
else
let indent = ''
endif
let dollar_expr = zencoding#getResource(type, 'dollar_expr', 1) let dollar_expr = zencoding#getResource(type, 'dollar_expr', 1)
let indent = zencoding#getIndentation(type)
let itemno = 0 let itemno = 0
let str = '' let str = ''
let use_pipe_for_cursor = zencoding#getResource(type, 'use_pipe_for_cursor', 1) let use_pipe_for_cursor = zencoding#getResource(type, 'use_pipe_for_cursor', 1)
@@ -209,7 +213,7 @@ function! zencoding#toString(...)
if len(current.child) if len(current.child)
let render_type = zencoding#getFileType(1) let render_type = zencoding#getFileType(1)
for n in current.child for n in current.child
let inner .= zencoding#toString(n, type, inline, filters, group_itemno) let inner .= zencoding#toString(n, type, inline, filters, group_itemno, indent)
endfor endfor
endif endif
let spaces = matchstr(str, '\s*\ze\${child}') let spaces = matchstr(str, '\s*\ze\${child}')
@@ -294,6 +298,7 @@ endfunction
function! zencoding#expandAbbr(mode, abbr) range function! zencoding#expandAbbr(mode, abbr) range
let type = zencoding#getFileType() let type = zencoding#getFileType()
let rtype = zencoding#getFileType(1) let rtype = zencoding#getFileType(1)
let indent = zencoding#getIndentation(type)
let expand = '' let expand = ''
let filters = ['html'] let filters = ['html']
let line = '' let line = ''
@@ -326,7 +331,7 @@ function! zencoding#expandAbbr(mode, abbr) range
endif endif
let items = zencoding#parseIntoTree(query, type).child let items = zencoding#parseIntoTree(query, type).child
for item in items for item in items
let expand .= zencoding#toString(item, type, 0, filters) let expand .= zencoding#toString(item, type, 0, filters, 0, indent)
endfor endfor
if zencoding#useFilter(filters, 'e') if zencoding#useFilter(filters, 'e')
let expand = substitute(expand, '&', '\&amp;', 'g') let expand = substitute(expand, '&', '\&amp;', 'g')
@@ -381,7 +386,7 @@ function! zencoding#expandAbbr(mode, abbr) range
let items = zencoding#parseIntoTree(leader . "{".str."}", type).child let items = zencoding#parseIntoTree(leader . "{".str."}", type).child
endif endif
for item in items for item in items
let expand .= zencoding#toString(item, type, 0, filters) let expand .= zencoding#toString(item, type, 0, filters, 0, '')
endfor endfor
if zencoding#useFilter(filters, 'e') if zencoding#useFilter(filters, 'e')
let expand = substitute(expand, '&', '\&amp;', 'g') let expand = substitute(expand, '&', '\&amp;', 'g')
@@ -421,7 +426,7 @@ function! zencoding#expandAbbr(mode, abbr) range
endif endif
let items = zencoding#parseIntoTree(str, rtype).child let items = zencoding#parseIntoTree(str, rtype).child
for item in items for item in items
let expand .= zencoding#toString(item, rtype, 0, filters) let expand .= zencoding#toString(item, rtype, 0, filters, 0, indent)
endfor endfor
if zencoding#useFilter(filters, 'e') if zencoding#useFilter(filters, 'e')
let expand = substitute(expand, '&', '\&amp;', 'g') let expand = substitute(expand, '&', '\&amp;', 'g')
@@ -620,6 +625,7 @@ function! zencoding#ExpandWord(abbr, type, orig)
let mx = '|\(\%(html\|haml\|slim\|e\|c\|fc\|xsl\|t\|\/[^ ]\+\)\s*,\{0,1}\s*\)*$' let mx = '|\(\%(html\|haml\|slim\|e\|c\|fc\|xsl\|t\|\/[^ ]\+\)\s*,\{0,1}\s*\)*$'
let str = a:abbr let str = a:abbr
let type = a:type let type = a:type
let indent = zencoding#getIndentation(type)
if len(type) == 0 | let type = 'html' | endif if len(type) == 0 | let type = 'html' | endif
if str =~ mx if str =~ mx
@@ -633,7 +639,7 @@ function! zencoding#ExpandWord(abbr, type, orig)
let items = zencoding#parseIntoTree(str, a:type).child let items = zencoding#parseIntoTree(str, a:type).child
let expand = '' let expand = ''
for item in items for item in items
let expand .= zencoding#toString(item, a:type, 0, filters) let expand .= zencoding#toString(item, a:type, 0, filters, 0, indent)
endfor endfor
if zencoding#useFilter(filters, 'e') if zencoding#useFilter(filters, 'e')
let expand = substitute(expand, '&', '\&amp;', 'g') let expand = substitute(expand, '&', '\&amp;', 'g')

View File

@@ -92,7 +92,7 @@ function! zencoding#lang#haml#toString(settings, current, type, inline, filters,
endif endif
elseif len(current.child) > 0 elseif len(current.child) > 0
for child in current.child for child in current.child
let inner .= zencoding#toString(child, type, inline, filters, itemno) let inner .= zencoding#toString(child, type, inline, filters, itemno, indent)
endfor endfor
let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g') let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g')
let inner = substitute(inner, "\n" . escape(indent, '\') . "$", "", 'g') let inner = substitute(inner, "\n" . escape(indent, '\') . "$", "", 'g')

View File

@@ -371,7 +371,7 @@ function! zencoding#lang#html#toString(settings, current, type, inline, filters,
let dr = 1 let dr = 1
endif endif
endif endif
let inner = zencoding#toString(child, type, 0, filters, itemno) let inner = zencoding#toString(child, type, 0, filters, itemno, indent)
let inner = substitute(inner, "^\n", "", 'g') let inner = substitute(inner, "^\n", "", 'g')
let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g') let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g')
let inner = substitute(inner, "\n" . escape(indent, '\') . '$', '', 'g') let inner = substitute(inner, "\n" . escape(indent, '\') . '$', '', 'g')

View File

@@ -68,7 +68,7 @@ function! zencoding#lang#slim#toString(settings, current, type, inline, filters,
endfor endfor
elseif len(current.child) > 0 elseif len(current.child) > 0
for child in current.child for child in current.child
let inner .= zencoding#toString(child, type, inline, filters, itemno) let inner .= zencoding#toString(child, type, inline, filters, itemno, indent)
endfor endfor
let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g') let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g')
let inner = substitute(inner, "\n" . escape(indent, '\') . "$", "", 'g') let inner = substitute(inner, "\n" . escape(indent, '\') . "$", "", 'g')