From 820977512973a8a2ee862c6dce9f046327073739 Mon Sep 17 00:00:00 2001 From: mattn Date: Fri, 6 Jul 2012 13:39:08 +0900 Subject: [PATCH] add new option dollar_expr that don't replace $ to numbers. --- autoload/zencoding/lang/haml.vim | 39 ++++++++++++++++++++------------ autoload/zencoding/lang/html.vim | 31 ++++++++++++++++--------- autoload/zencoding/lang/slim.vim | 37 +++++++++++++++++++----------- 3 files changed, 69 insertions(+), 38 deletions(-) diff --git a/autoload/zencoding/lang/haml.vim b/autoload/zencoding/lang/haml.vim index 6d6ee0f..bb88bbf 100644 --- a/autoload/zencoding/lang/haml.vim +++ b/autoload/zencoding/lang/haml.vim @@ -14,21 +14,26 @@ function! zencoding#lang#haml#toString(settings, current, type, inline, filters, let filters = a:filters let itemno = a:itemno let indent = a:indent + let dollar_expr = zencoding#getResource(type, 'dollar_expr', 1) let str = "" let comment_indent = '' let comment = '' let current_name = current.name - let current_name = substitute(current.name, '\$$', itemno+1, '') + if dollar_expr + let current_name = substitute(current.name, '\$$', itemno+1, '') + endif if len(current.name) > 0 let str .= '%' . current_name let tmp = '' for attr in keys(current.attr) let val = current.attr[attr] - while val =~ '\$\([^#{]\|$\)' - let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g') - endwhile - let attr = substitute(attr, '\$$', itemno+1, '') + 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 @@ -50,9 +55,11 @@ function! zencoding#lang#haml#toString(settings, current, type, inline, filters, let inner = '' if len(current.value) > 0 let text = current.value[1:-2] - let text = substitute(text, '\%(\\\)\@\ 0 let str .= '<' . current_name for attr in keys(current.attr) let val = current.attr[attr] - while val =~ '\$\([^#{]\|$\)' - let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g') - endwhile - let attr = substitute(attr, '\$$', itemno+1, '') + 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 str .= ' ' . attr . '="' . val . '"' if zencoding#useFilter(filters, 'c') if attr == 'id' | let comment .= '#' . val | endif @@ -332,9 +339,11 @@ function! zencoding#lang#html#toString(settings, current, type, inline, filters, else let str .= ">" let text = current.value[1:-2] - let text = substitute(text, '\%(\\\)\@\ 0 let str .= current_name for attr in keys(current.attr) let val = current.attr[attr] - while val =~ '\$\([^#{]\|$\)' - let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g') - 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 . '"' endfor @@ -35,9 +40,11 @@ function! zencoding#lang#slim#toString(settings, current, type, inline, filters, if len(current.value) > 0 let str .= "\n" let text = current.value[1:-2] - let text = substitute(text, '\%(\\\)\@\