forked from VimPlug/emmet-vim
Support boolean attributes, related issue #170
This commit is contained in:
@@ -30,22 +30,26 @@ function! emmet#lang#haml#toString(settings, current, type, inline, filters, ite
|
||||
if !has_key(current.attr, attr)
|
||||
continue
|
||||
endif
|
||||
let val = current.attr[attr]
|
||||
if dollar_expr
|
||||
while val =~ '\$\([^#{]\|$\)'
|
||||
let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
endwhile
|
||||
let attr = substitute(attr, '\$$', itemno+1, '')
|
||||
endif
|
||||
let valtmp = substitute(val, '\${cursor}', '', '')
|
||||
if attr == 'id' && len(valtmp) > 0
|
||||
let str .= '#' . val
|
||||
elseif attr == 'class' && len(valtmp) > 0
|
||||
let str .= '.' . substitute(val, ' ', '.', 'g')
|
||||
else
|
||||
if len(tmp) > 0 | let tmp .= ',' | endif
|
||||
let val = substitute(val, '\${cursor}', '', '')
|
||||
let tmp .= ' :' . attr . ' => "' . val . '"'
|
||||
let Val = current.attr[attr]
|
||||
if type(Val) == 2 && Val == function('emmet#types#true')
|
||||
let tmp .= ' :' . attr . ' => true'
|
||||
else
|
||||
if dollar_expr
|
||||
while Val =~ '\$\([^#{]\|$\)'
|
||||
let Val = substitute(Val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
endwhile
|
||||
let attr = substitute(attr, '\$$', itemno+1, '')
|
||||
endif
|
||||
let valtmp = substitute(Val, '\${cursor}', '', '')
|
||||
if attr == 'id' && len(valtmp) > 0
|
||||
let str .= '#' . Val
|
||||
elseif attr == 'class' && len(valtmp) > 0
|
||||
let str .= '.' . substitute(Val, ' ', '.', 'g')
|
||||
else
|
||||
if len(tmp) > 0 | let tmp .= ',' | endif
|
||||
let Val = substitute(Val, '\${cursor}', '', '')
|
||||
let tmp .= ' :' . attr . ' => "' . Val . '"'
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
if len(tmp)
|
||||
|
||||
@@ -197,15 +197,20 @@ function! emmet#lang#html#parseIntoTree(abbr, type)
|
||||
break
|
||||
endif
|
||||
let key = split(amat, '=')[0]
|
||||
let val = amat[len(key)+1:]
|
||||
if val =~ '^["'']'
|
||||
let val = val[1:-2]
|
||||
let Val = amat[len(key)+1:]
|
||||
if key =~ '\.$' && Val == ''
|
||||
let key = key[:-2]
|
||||
unlet Val
|
||||
let Val = function('emmet#types#true')
|
||||
elseif Val =~ '^["'']'
|
||||
let Val = Val[1:-2]
|
||||
endif
|
||||
let current.attr[key] = val
|
||||
let current.attr[key] = Val
|
||||
if index(current.attrs_order, key) == -1
|
||||
let current.attrs_order += [key]
|
||||
endif
|
||||
let atts = atts[stridx(atts, amat) + len(amat):]
|
||||
unlet Val
|
||||
endwhile
|
||||
endif
|
||||
let attr = substitute(strpart(attr, len(item)), '^\s*', '', '')
|
||||
@@ -355,22 +360,36 @@ function! emmet#lang#html#toString(settings, current, type, inline, filters, ite
|
||||
if !has_key(current.attr, attr)
|
||||
continue
|
||||
endif
|
||||
let val = current.attr[attr]
|
||||
if dollar_expr
|
||||
while val =~ '\$\([^#{]\|$\)'
|
||||
" TODO: regexp engine specified
|
||||
if exists('®expengine')
|
||||
let val = substitute(val, '\%#=1\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
else
|
||||
let val = substitute(val, '\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
endif
|
||||
endwhile
|
||||
let attr = substitute(attr, '\$$', itemno+1, '')
|
||||
endif
|
||||
let str .= ' ' . attr . '="' . val . '"'
|
||||
if emmet#useFilter(filters, 'c')
|
||||
if attr == 'id' | let comment .= '#' . val | endif
|
||||
if attr == 'class' | let comment .= '.' . val | endif
|
||||
let Val = current.attr[attr]
|
||||
if type(Val) == 2 && Val == function('emmet#types#true')
|
||||
unlet Val
|
||||
let Val = 'true'
|
||||
if g:emmet_html5
|
||||
let str .= ' ' . attr
|
||||
else
|
||||
let str .= ' ' . attr . '="' . attr . '"'
|
||||
endif
|
||||
if emmet#useFilter(filters, 'c')
|
||||
if attr == 'id' | let comment .= '#' . Val | endif
|
||||
if attr == 'class' | let comment .= '.' . Val | endif
|
||||
endif
|
||||
else
|
||||
if dollar_expr
|
||||
while Val =~ '\$\([^#{]\|$\)'
|
||||
" TODO: regexp engine specified
|
||||
if exists('®expengine')
|
||||
let Val = substitute(Val, '\%#=1\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
else
|
||||
let Val = substitute(Val, '\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
endif
|
||||
endwhile
|
||||
let attr = substitute(attr, '\$$', itemno+1, '')
|
||||
endif
|
||||
let str .= ' ' . attr . '="' . Val . '"'
|
||||
if emmet#useFilter(filters, 'c')
|
||||
if attr == 'id' | let comment .= '#' . Val | endif
|
||||
if attr == 'class' | let comment .= '.' . Val | endif
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
if len(comment) > 0
|
||||
|
||||
@@ -29,14 +29,18 @@ function! emmet#lang#slim#toString(settings, current, type, inline, filters, ite
|
||||
if !has_key(current.attr, attr)
|
||||
continue
|
||||
endif
|
||||
let val = current.attr[attr]
|
||||
if dollar_expr
|
||||
while val =~ '\$\([^#{]\|$\)'
|
||||
let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
endwhile
|
||||
let Val = current.attr[attr]
|
||||
if type(Val) == 2 && Val == function('emmet#types#true')
|
||||
let str .= ' ' . attr . '=true'
|
||||
else
|
||||
if dollar_expr
|
||||
while Val =~ '\$\([^#{]\|$\)'
|
||||
let Val = substitute(Val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
endwhile
|
||||
endif
|
||||
let attr = substitute(attr, '\$$', itemno+1, '')
|
||||
let str .= ' ' . attr . '="' . Val . '"'
|
||||
endif
|
||||
let attr = substitute(attr, '\$$', itemno+1, '')
|
||||
let str .= ' ' . attr . '="' . val . '"'
|
||||
endfor
|
||||
|
||||
let inner = ''
|
||||
|
||||
Reference in New Issue
Block a user