Separate rendering type and filetype

This commit is contained in:
mattn
2013-04-09 19:18:41 +09:00
parent 857809e676
commit 6d07bd9752

View File

@@ -207,6 +207,7 @@ function! zencoding#toString(...)
endif endif
let inner = '' let inner = ''
if len(current.child) if len(current.child)
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)
endfor endfor
@@ -256,12 +257,20 @@ function! zencoding#getResource(type, name, default)
return ret return ret
endfunction endfunction
function! zencoding#getFileType() function! zencoding#getFileType(...)
let flg = get(a:000, 0, 0)
let type = &ft let type = &ft
if zencoding#lang#exists(&ft) if zencoding#lang#exists(&ft)
let type = &ft let type = &ft
elseif zencoding#getBaseType(type) != "" else
let base = zencoding#getBaseType(type)
if base != ""
if flg
let type = &ft let type = &ft
else
let type = base
endif
endif
endif endif
if type == 'html' if type == 'html'
let type = synIDattr(synID(line("."), col("."), 1), "name") let type = synIDattr(synID(line("."), col("."), 1), "name")
@@ -284,6 +293,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 expand = '' let expand = ''
let filters = ['html'] let filters = ['html']
let line = '' let line = ''
@@ -399,8 +409,8 @@ function! zencoding#expandAbbr(mode, abbr) range
let part = matchstr(line, '\([a-zA-Z0-9:_\-\@|]\+\)$') let part = matchstr(line, '\([a-zA-Z0-9:_\-\@|]\+\)$')
else else
let part = matchstr(line, '\(\S.*\)$') let part = matchstr(line, '\(\S.*\)$')
let rtype = zencoding#lang#exists(type) ? type : 'html' let ftype = zencoding#lang#exists(type) ? type : 'html'
let part = zencoding#lang#{rtype}#findTokens(part) let part = zencoding#lang#{ftype}#findTokens(part)
endif endif
let rest = getline('.')[len(line):] let rest = getline('.')[len(line):]
let str = part let str = part
@@ -409,9 +419,9 @@ function! zencoding#expandAbbr(mode, abbr) range
let filters = split(matchstr(str, mx)[1:], '\s*,\s*') let filters = split(matchstr(str, mx)[1:], '\s*,\s*')
let str = substitute(str, mx, '', '') let str = substitute(str, mx, '', '')
endif endif
let items = zencoding#parseIntoTree(str, type).child let items = zencoding#parseIntoTree(str, rtype).child
for item in items for item in items
let expand .= zencoding#toString(item, type, 0, filters) let expand .= zencoding#toString(item, rtype, 0, filters)
endfor endfor
if zencoding#useFilter(filters, 'e') if zencoding#useFilter(filters, 'e')
let expand = substitute(expand, '&', '\&', 'g') let expand = substitute(expand, '&', '\&', 'g')