From 65d61396541c563ede37de7abd052453af5e5648 Mon Sep 17 00:00:00 2001 From: mattn Date: Fri, 28 Oct 2011 10:22:20 +0900 Subject: add {{_if_:foo;bar;baz}}. --- plugin/template.vim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'plugin') diff --git a/plugin/template.vim b/plugin/template.vim index a6cbc59..dd742a5 100644 --- a/plugin/template.vim +++ b/plugin/template.vim @@ -70,6 +70,7 @@ function! s:Template(name) abort let val = input(var . ":") let c = substitute(c, '\V{{_input_:'.var.'}}', '\=val', 'g') endfor + let c = substitute(c, '{{_if_:\(.\{-}\);\(.\{-}\)\(;\(.\{-}\)\)\{-}}}', '\=eval(submatch(1))?submatch(2):submatch(4)', 'g') let c = substitute(c, '{{_expr_:\(.\{-}\)}}', '\=eval(submatch(1))', 'g') if len(c) == 0 return @@ -96,8 +97,9 @@ function! s:Template(name) abort if stridx(c, '{{_cursor_}}') silent! call search('{{_cursor_}}', 'w') silent! s/{{_cursor_}}//g - silent! exe "normal! \" endif + silent! exe "normal! \" + startinsert endfunction " vim:ts=4:sw=4:et -- cgit v1.2.3-54-g00ecf