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)
|
if !has_key(current.attr, attr)
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
let val = current.attr[attr]
|
let Val = current.attr[attr]
|
||||||
if dollar_expr
|
if type(Val) == 2 && Val == function('emmet#types#true')
|
||||||
while val =~ '\$\([^#{]\|$\)'
|
let tmp .= ' :' . attr . ' => true'
|
||||||
let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
else
|
||||||
endwhile
|
if dollar_expr
|
||||||
let attr = substitute(attr, '\$$', itemno+1, '')
|
while Val =~ '\$\([^#{]\|$\)'
|
||||||
endif
|
let Val = substitute(Val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||||
let valtmp = substitute(val, '\${cursor}', '', '')
|
endwhile
|
||||||
if attr == 'id' && len(valtmp) > 0
|
let attr = substitute(attr, '\$$', itemno+1, '')
|
||||||
let str .= '#' . val
|
endif
|
||||||
elseif attr == 'class' && len(valtmp) > 0
|
let valtmp = substitute(Val, '\${cursor}', '', '')
|
||||||
let str .= '.' . substitute(val, ' ', '.', 'g')
|
if attr == 'id' && len(valtmp) > 0
|
||||||
else
|
let str .= '#' . Val
|
||||||
if len(tmp) > 0 | let tmp .= ',' | endif
|
elseif attr == 'class' && len(valtmp) > 0
|
||||||
let val = substitute(val, '\${cursor}', '', '')
|
let str .= '.' . substitute(Val, ' ', '.', 'g')
|
||||||
let tmp .= ' :' . attr . ' => "' . val . '"'
|
else
|
||||||
|
if len(tmp) > 0 | let tmp .= ',' | endif
|
||||||
|
let Val = substitute(Val, '\${cursor}', '', '')
|
||||||
|
let tmp .= ' :' . attr . ' => "' . Val . '"'
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
if len(tmp)
|
if len(tmp)
|
||||||
|
|||||||
@@ -197,15 +197,20 @@ function! emmet#lang#html#parseIntoTree(abbr, type)
|
|||||||
break
|
break
|
||||||
endif
|
endif
|
||||||
let key = split(amat, '=')[0]
|
let key = split(amat, '=')[0]
|
||||||
let val = amat[len(key)+1:]
|
let Val = amat[len(key)+1:]
|
||||||
if val =~ '^["'']'
|
if key =~ '\.$' && Val == ''
|
||||||
let val = val[1:-2]
|
let key = key[:-2]
|
||||||
|
unlet Val
|
||||||
|
let Val = function('emmet#types#true')
|
||||||
|
elseif Val =~ '^["'']'
|
||||||
|
let Val = Val[1:-2]
|
||||||
endif
|
endif
|
||||||
let current.attr[key] = val
|
let current.attr[key] = Val
|
||||||
if index(current.attrs_order, key) == -1
|
if index(current.attrs_order, key) == -1
|
||||||
let current.attrs_order += [key]
|
let current.attrs_order += [key]
|
||||||
endif
|
endif
|
||||||
let atts = atts[stridx(atts, amat) + len(amat):]
|
let atts = atts[stridx(atts, amat) + len(amat):]
|
||||||
|
unlet Val
|
||||||
endwhile
|
endwhile
|
||||||
endif
|
endif
|
||||||
let attr = substitute(strpart(attr, len(item)), '^\s*', '', '')
|
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)
|
if !has_key(current.attr, attr)
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
let val = current.attr[attr]
|
let Val = current.attr[attr]
|
||||||
if dollar_expr
|
if type(Val) == 2 && Val == function('emmet#types#true')
|
||||||
while val =~ '\$\([^#{]\|$\)'
|
unlet Val
|
||||||
" TODO: regexp engine specified
|
let Val = 'true'
|
||||||
if exists('®expengine')
|
if g:emmet_html5
|
||||||
let val = substitute(val, '\%#=1\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
let str .= ' ' . attr
|
||||||
else
|
else
|
||||||
let val = substitute(val, '\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
let str .= ' ' . attr . '="' . attr . '"'
|
||||||
endif
|
endif
|
||||||
endwhile
|
if emmet#useFilter(filters, 'c')
|
||||||
let attr = substitute(attr, '\$$', itemno+1, '')
|
if attr == 'id' | let comment .= '#' . Val | endif
|
||||||
endif
|
if attr == 'class' | let comment .= '.' . Val | endif
|
||||||
let str .= ' ' . attr . '="' . val . '"'
|
endif
|
||||||
if emmet#useFilter(filters, 'c')
|
else
|
||||||
if attr == 'id' | let comment .= '#' . val | endif
|
if dollar_expr
|
||||||
if attr == 'class' | let comment .= '.' . val | endif
|
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
|
endif
|
||||||
endfor
|
endfor
|
||||||
if len(comment) > 0
|
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)
|
if !has_key(current.attr, attr)
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
let val = current.attr[attr]
|
let Val = current.attr[attr]
|
||||||
if dollar_expr
|
if type(Val) == 2 && Val == function('emmet#types#true')
|
||||||
while val =~ '\$\([^#{]\|$\)'
|
let str .= ' ' . attr . '=true'
|
||||||
let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
else
|
||||||
endwhile
|
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
|
endif
|
||||||
let attr = substitute(attr, '\$$', itemno+1, '')
|
|
||||||
let str .= ' ' . attr . '="' . val . '"'
|
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
let inner = ''
|
let inner = ''
|
||||||
|
|||||||
Reference in New Issue
Block a user