forked from VimPlug/emmet-vim
@@ -196,6 +196,18 @@ function! s:itemno(itemno, current) abort
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:localvar(current, key) abort
|
||||||
|
let val = ''
|
||||||
|
let cur = a:current
|
||||||
|
while !empty(cur)
|
||||||
|
if has_key(cur, 'variables') && has_key(cur.variables, a:key)
|
||||||
|
return cur.variables[a:key]
|
||||||
|
endif
|
||||||
|
let cur = cur.parent
|
||||||
|
endwhile
|
||||||
|
return ''
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! emmet#toString(...) abort
|
function! emmet#toString(...) abort
|
||||||
let current = a:1
|
let current = a:1
|
||||||
if a:0 > 1
|
if a:0 > 1
|
||||||
@@ -291,6 +303,7 @@ function! emmet#toString(...) abort
|
|||||||
let inner = current.value[1:-2]
|
let inner = current.value[1:-2]
|
||||||
endif
|
endif
|
||||||
let inner = substitute(inner, "\n", "\n" . indent, 'g')
|
let inner = substitute(inner, "\n", "\n" . indent, 'g')
|
||||||
|
let str = substitute(str, '\${\(\w\+\)}', '\=s:localvar(current, submatch(1))', '')
|
||||||
let str = substitute(str, '\${child}', inner, '')
|
let str = substitute(str, '\${child}', inner, '')
|
||||||
endif
|
endif
|
||||||
let itemno = itemno + 1
|
let itemno = itemno + 1
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ function! emmet#lang#html#parseIntoTree(abbr, type) abort
|
|||||||
let abbr = rabbr
|
let abbr = rabbr
|
||||||
|
|
||||||
let root = emmet#newNode()
|
let root = emmet#newNode()
|
||||||
|
let root['variables'] = {}
|
||||||
let parent = root
|
let parent = root
|
||||||
let last = root
|
let last = root
|
||||||
let pos = []
|
let pos = []
|
||||||
@@ -257,9 +258,11 @@ function! emmet#lang#html#parseIntoTree(abbr, type) abort
|
|||||||
endif
|
endif
|
||||||
if item[0] ==# '#'
|
if item[0] ==# '#'
|
||||||
let current.attr.id = item[1:]
|
let current.attr.id = item[1:]
|
||||||
|
let root['variables']['id'] = current.attr.id
|
||||||
endif
|
endif
|
||||||
if item[0] ==# '.'
|
if item[0] ==# '.'
|
||||||
let current.attr.class = substitute(item[1:], '\.', ' ', 'g')
|
let current.attr.class = substitute(item[1:], '\.', ' ', 'g')
|
||||||
|
let root['variables']['class'] = current.attr.class
|
||||||
endif
|
endif
|
||||||
if item[0] ==# '['
|
if item[0] ==# '['
|
||||||
let atts = item[1:-2]
|
let atts = item[1:-2]
|
||||||
|
|||||||
Reference in New Issue
Block a user