Vital.Data.String.Interpolation is String interpolation1 library.
Farewell 'ugly' . 'dot' . 'string' . 'concatenation'
and meets the 'beautiful ${string} interpolation'
💓
vital.vim: https://github.com/vim-jp/vital.vim
NeoBundle 'vim-jp/vital.vim'
NeoBundle 'haya14busa/vital-string-interpolation'
Plugin 'vim-jp/vital.vim'
Plugin 'haya14busa/vital-string-interpolation'
Plug 'vim-jp/vital.vim'
Plug 'haya14busa/vital-string-interpolation'
2. Embed vital-string-interpolation into your plugin with :Vitalize (assume current directory is the root of your plugin repository).
See :Vitalize
for more information.
:Vitalize . --name={plugin_name} Data.String.Interpolation
:Vitalize .
let s:V = vital#of("vital")
let s:I = s:V.import("Data.String.Interpolation")
echo s:I.interpolate('Hi, ${name}!', {'name': 'haya14busa'})
" => Hi, haya14busa!
let scores = [
\ {'name': 'haya14busa', 'score': 14},
\ {'name': 'tom', 'score': 32}
\ ]
for score in scores
echo s:I.format('Hi, ${name}. Your SCORE is ${score}!', score)
endfor
" => Hi, haya14busa. Your SCORE is 14!
" => Hi, tom. Your SCORE is 32!
" You can just pass :h internal-variables as a context.
function! s:IIFE() abort
let name = 'haya14busa'
return s:I.s('Hi, ${name}!', l:)
endfunction
echo s:IIFE()
" => Hi, haya14busa!
haya14busa (https://github.com/haya14busa)