mirror of
https://github.com/mattn/emmet-vim.git
synced 2025-12-08 03:24:45 +08:00
Merge pull request #114 from mgrubb/keep-attribute-order
Keep defined order of HTML attributes
This commit is contained in:
@@ -92,7 +92,7 @@ function! zencoding#lang#html#parseIntoTree(abbr, type)
|
|||||||
if multiplier <= 0 | let multiplier = 1 | endif
|
if multiplier <= 0 | let multiplier = 1 | endif
|
||||||
|
|
||||||
" make default node
|
" make default node
|
||||||
let current = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0, 'important': 0 }
|
let current = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0, 'important': 0, 'attrs_order': ['id', 'class'] }
|
||||||
let current.name = tag_name
|
let current.name = tag_name
|
||||||
|
|
||||||
let current.important = important
|
let current.important = important
|
||||||
@@ -182,6 +182,7 @@ function! zencoding#lang#html#parseIntoTree(abbr, type)
|
|||||||
let val = val[1:-2]
|
let val = val[1:-2]
|
||||||
endif
|
endif
|
||||||
let current.attr[key] = val
|
let current.attr[key] = val
|
||||||
|
let current.attrs_order = current.attrs_order + [key]
|
||||||
let atts = atts[stridx(atts, amat) + len(amat):]
|
let atts = atts[stridx(atts, amat) + len(amat):]
|
||||||
endwhile
|
endwhile
|
||||||
endif
|
endif
|
||||||
@@ -317,7 +318,8 @@ function! zencoding#lang#html#toString(settings, current, type, inline, filters,
|
|||||||
endif
|
endif
|
||||||
if len(current_name) > 0
|
if len(current_name) > 0
|
||||||
let str .= '<' . current_name
|
let str .= '<' . current_name
|
||||||
for attr in keys(current.attr)
|
for attr in current.attrs_order
|
||||||
|
if (has_key(current.attr, attr))
|
||||||
let val = current.attr[attr]
|
let val = current.attr[attr]
|
||||||
if dollar_expr
|
if dollar_expr
|
||||||
while val =~ '\$\([^#{]\|$\)'
|
while val =~ '\$\([^#{]\|$\)'
|
||||||
@@ -330,6 +332,7 @@ function! zencoding#lang#html#toString(settings, current, type, inline, filters,
|
|||||||
if attr == 'id' | let comment .= '#' . val | endif
|
if attr == 'id' | let comment .= '#' . val | endif
|
||||||
if attr == 'class' | let comment .= '.' . val | endif
|
if attr == 'class' | let comment .= '.' . val | endif
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
endfor
|
endfor
|
||||||
if len(comment) > 0
|
if len(comment) > 0
|
||||||
let str = "<!-- " . comment . " -->\n" . str
|
let str = "<!-- " . comment . " -->\n" . str
|
||||||
|
|||||||
Reference in New Issue
Block a user