Squashed 'vim/bundle/mustache/' content from commit 0c3900b42
git-subtree-dir: vim/bundle/mustache git-subtree-split: 0c3900b42a81ec79885cf984ad33b2280697c7c9main
commit
1a9b6d1c2a
@ -0,0 +1,96 @@
|
|||||||
|
mustache and handlebars mode for vim
|
||||||
|
====================================
|
||||||
|
|
||||||
|
**Note**: This repo is deprecated, active development moved to
|
||||||
|
[mustache/vim-mode](http://github.com/mustache/vim-mode).
|
||||||
|
|
||||||
|
A vim plugin for working with [mustache][mustache] and
|
||||||
|
[handlebars][handlebars] templates. It has:
|
||||||
|
|
||||||
|
- syntax highlighting
|
||||||
|
- matchit support
|
||||||
|
- mustache abbreviations (optional)
|
||||||
|
- section movement mappings `[[` and `]]`
|
||||||
|
|
||||||
|
|
||||||
|
### Install for pathogen
|
||||||
|
|
||||||
|
cd ~/.vim/
|
||||||
|
git submodule add git://github.com/mustache/vim-mode.git bundle/mustache
|
||||||
|
vim bundle/mustache/example.mustache
|
||||||
|
|
||||||
|
Get [pathogen][pathogen].
|
||||||
|
|
||||||
|
### Manually Install
|
||||||
|
|
||||||
|
cd ~/.local/src
|
||||||
|
git clone git://github.com/mustache/vim-mode.git mustache.vim
|
||||||
|
cp -R mustache.vim/syntax/* ~/.vim/syntax/
|
||||||
|
cp -R mustache.vim/ftdetect/* ~/.vim/ftdetect/
|
||||||
|
cp -R mustache.vim/ftplugin/* ~/.vim/ftplugin/
|
||||||
|
vim mustache.vim/example.mustache
|
||||||
|
|
||||||
|
### Mustache Abbreviations
|
||||||
|
|
||||||
|
You can activate mustache abbreviations by putting this line in your `.vimrc`:
|
||||||
|
`let g:mustache_abbreviations = 1`
|
||||||
|
|
||||||
|
Now you get a set of convenient abbreviations. Underscore `_` indicates where
|
||||||
|
your cursor ends up after typing an abbreviation:
|
||||||
|
- `{{` => `{{_}}`
|
||||||
|
- `{{{` => `{{{_}}}`
|
||||||
|
- `{{!` => `{{!_}}`
|
||||||
|
- `{{>` => `{{>_}}`
|
||||||
|
- `{{<` => `{{<_}}`
|
||||||
|
- `{{#` produces
|
||||||
|
|
||||||
|
```
|
||||||
|
{{# _}}
|
||||||
|
{{/}}
|
||||||
|
```
|
||||||
|
- `{{if` produces
|
||||||
|
|
||||||
|
```
|
||||||
|
{{#if _}}
|
||||||
|
{{/if}}
|
||||||
|
```
|
||||||
|
- `{{ife` produces
|
||||||
|
|
||||||
|
```
|
||||||
|
{{#if _}}
|
||||||
|
{{else}}
|
||||||
|
{{/if}}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Section movement mappings
|
||||||
|
|
||||||
|
Following the vim convention of jumping from section to section, `[[` and `]]`
|
||||||
|
mappings are implemented for easier movement between mustache tags.
|
||||||
|
|
||||||
|
- `]]` jumps to the first following tag
|
||||||
|
- `[[` jumps to the first previous tag
|
||||||
|
|
||||||
|
Count with section movements is supported:
|
||||||
|
|
||||||
|
- `2]]` jumps to the second next tag
|
||||||
|
|
||||||
|
## Maintainers
|
||||||
|
|
||||||
|
* [Bruno Michel](http://github.com/nono)
|
||||||
|
* [Bruno Sutic](http://github.com/bruno-)
|
||||||
|
* [Juvenn Woo](http://github.com/juvenn)
|
||||||
|
|
||||||
|
This is combined work from
|
||||||
|
[juvenn/mustache.vim](http://github.com/juvenn/mustache.vim) and
|
||||||
|
[nono/vim-handlebars](http://github.com/nono/vim-handlebars).
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
Thanks [@5long](http://github.com/5long) for adding matchit support.
|
||||||
|
|
||||||
|
You're encouraged to propose ideas or have discussions via github
|
||||||
|
issues.
|
||||||
|
|
||||||
|
[mustache]: http://mustache.github.io
|
||||||
|
[handlebars]: http://handlebarsjs.com
|
||||||
|
[pathogen]: https://github.com/tpope/vim-pathogen
|
@ -0,0 +1,50 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>
|
||||||
|
{{title}}
|
||||||
|
</title>
|
||||||
|
{{!}}
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="main">
|
||||||
|
<h1>Mustache Showdown</h1>
|
||||||
|
|
||||||
|
Basic mustache {{hello}}
|
||||||
|
{{ hello}}, {{hello }} and {{ hello }} are OK
|
||||||
|
|
||||||
|
<de>{{d d d}}
|
||||||
|
|
||||||
|
{{Everything will be hilighted here}}
|
||||||
|
|
||||||
|
Mustaches hilighted in
|
||||||
|
<span class="color:{{awesome_color}};font-size:1.2em">attribute value</span>
|
||||||
|
|
||||||
|
{{#repo}}
|
||||||
|
This is an mustache [enumerable] section
|
||||||
|
<li>{{ name }}</li>
|
||||||
|
{{/repo}}
|
||||||
|
|
||||||
|
You can {{{yield}}} here
|
||||||
|
|
||||||
|
{{! <> this is a comment TODO:}}
|
||||||
|
|
||||||
|
This is a partial {{> partial1 }}
|
||||||
|
Yet another partial {{< partial2 }}, for ctemplate
|
||||||
|
|
||||||
|
{{=<% %>=}}Sorry, cusomized delimiter not handled yet<%={{}}=%>
|
||||||
|
|
||||||
|
{{#if some_helper}}
|
||||||
|
And here is an example of handlebars if...
|
||||||
|
{{else}}
|
||||||
|
... with optional else added. Try matchit `%` command over if/else/if.
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
Thanks goes to {{@defunkt}}
|
||||||
|
Feedback/blames go to {{@juvenn}}
|
||||||
|
{{Frustrations}} go to /dev/null
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,3 @@
|
|||||||
|
if has("autocmd")
|
||||||
|
au BufNewFile,BufRead *.mustache,*.handlebars,*.hbs,*.hogan,*.hulk,*.hjs set filetype=html syntax=mustache | runtime! ftplugin/mustache.vim ftplugin/mustache*.vim ftplugin/mustache/*.vim
|
||||||
|
endif
|
@ -0,0 +1,63 @@
|
|||||||
|
let s:cpo_save = &cpo
|
||||||
|
set cpo&vim
|
||||||
|
|
||||||
|
" Matchit support for Mustache & Handlebars
|
||||||
|
" extending HTML matchit groups
|
||||||
|
if exists("loaded_matchit") && exists("b:match_words")
|
||||||
|
let b:match_words = b:match_words
|
||||||
|
\ . ',{:},[:],(:),'
|
||||||
|
\ . '\%({{\)\@<=#\s*\%(if\|unless\)\s*.\{-}}}'
|
||||||
|
\ . ':'
|
||||||
|
\ . '\%({{\)\@<=\s*else\s*}}'
|
||||||
|
\ . ':'
|
||||||
|
\ . '\%({{\)\@<=/\s*\%(if\|unless\)\s*}},'
|
||||||
|
\ . '\%({{\)\@<=[#^]\s*\([-0-9a-zA-Z_?!/.]\+\).\{-}}}'
|
||||||
|
\ . ':'
|
||||||
|
\ . '\%({{\)\@<=/\s*\1\s*}}'
|
||||||
|
endif
|
||||||
|
|
||||||
|
if exists("g:mustache_abbreviations")
|
||||||
|
inoremap <buffer> {{{ {{{}}}<left><left><left>
|
||||||
|
inoremap <buffer> {{ {{}}<left><left>
|
||||||
|
inoremap <buffer> {{! {{!}}<left><left>
|
||||||
|
inoremap <buffer> {{< {{<}}<left><left>
|
||||||
|
inoremap <buffer> {{> {{>}}<left><left>
|
||||||
|
inoremap <buffer> {{# {{#}}<cr>{{/}}<up><left><left>
|
||||||
|
inoremap <buffer> {{if {{#if }}<cr>{{/if}}<up><left>
|
||||||
|
inoremap <buffer> {{ife {{#if }}<cr>{{else}}<cr>{{/if}}<up><up><left>
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
" Section movement
|
||||||
|
" Adapted from vim-ruby - many thanks to the maintainers of that plugin
|
||||||
|
|
||||||
|
function! s:sectionmovement(pattern,flags,mode,count)
|
||||||
|
norm! m'
|
||||||
|
if a:mode ==# 'v'
|
||||||
|
norm! gv
|
||||||
|
endif
|
||||||
|
let i = 0
|
||||||
|
while i < a:count
|
||||||
|
let i = i + 1
|
||||||
|
" saving current position
|
||||||
|
let line = line('.')
|
||||||
|
let col = col('.')
|
||||||
|
let pos = search(a:pattern,'W'.a:flags)
|
||||||
|
" if there's no more matches, return to last position
|
||||||
|
if pos == 0
|
||||||
|
call cursor(line,col)
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
endwhile
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
nnoremap <silent> <buffer> [[ :<C-U>call <SID>sectionmovement('{{','b','n',v:count1)<CR>
|
||||||
|
nnoremap <silent> <buffer> ]] :<C-U>call <SID>sectionmovement('{{','' ,'n',v:count1)<CR>
|
||||||
|
xnoremap <silent> <buffer> [[ :<C-U>call <SID>sectionmovement('{{','b','v',v:count1)<CR>
|
||||||
|
xnoremap <silent> <buffer> ]] :<C-U>call <SID>sectionmovement('{{','' ,'v',v:count1)<CR>
|
||||||
|
|
||||||
|
|
||||||
|
let &cpo = s:cpo_save
|
||||||
|
unlet s:cpo_save
|
||||||
|
|
||||||
|
" vim: nofoldenable
|
@ -0,0 +1,75 @@
|
|||||||
|
" Mustache & Handlebars syntax
|
||||||
|
" Language: Mustache, Handlebars
|
||||||
|
" Maintainer: Juvenn Woo <machese@gmail.com>
|
||||||
|
" Screenshot: http://imgur.com/6F408
|
||||||
|
" Version: 2
|
||||||
|
" Last Change: Mar 24th 2013
|
||||||
|
" Remark:
|
||||||
|
" It lexically hilights embedded mustaches (exclusively) in html file.
|
||||||
|
" While it was written for Ruby-based Mustache template system, it should
|
||||||
|
" work for Google's C-based *ctemplate* as well as Erlang-based *et*. All
|
||||||
|
" of them are, AFAIK, based on the idea of ctemplate.
|
||||||
|
" References:
|
||||||
|
" [Mustache](http://github.com/defunkt/mustache)
|
||||||
|
" [Handlebars](https://github.com/wycats/handlebars.js)
|
||||||
|
" [ctemplate](http://code.google.com/p/google-ctemplate/)
|
||||||
|
" [ctemplate doc](http://google-ctemplate.googlecode.com/svn/trunk/doc/howto.html)
|
||||||
|
" [et](http://www.ivan.fomichev.name/2008/05/erlang-template-engine-prototype.html)
|
||||||
|
" TODO: Feedback is welcomed.
|
||||||
|
|
||||||
|
|
||||||
|
" Read the HTML syntax to start with
|
||||||
|
if version < 600
|
||||||
|
so <sfile>:p:h/html.vim
|
||||||
|
else
|
||||||
|
runtime! syntax/html.vim
|
||||||
|
unlet b:current_syntax
|
||||||
|
endif
|
||||||
|
|
||||||
|
if version < 600
|
||||||
|
syntax clear
|
||||||
|
elseif exists("b:current_syntax")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Standard HiLink will not work with included syntax files
|
||||||
|
if version < 508
|
||||||
|
command! -nargs=+ HtmlHiLink hi link <args>
|
||||||
|
else
|
||||||
|
command! -nargs=+ HtmlHiLink hi def link <args>
|
||||||
|
endif
|
||||||
|
|
||||||
|
syntax match mustacheError '}}}\?'
|
||||||
|
syntax match mustacheInsideError '{{[{#<>=!\/]\?' containedin=@mustacheInside
|
||||||
|
syntax region mustacheVariable matchgroup=mustacheMarker start=/{{/ end=/}}/ containedin=@htmlMustacheContainer
|
||||||
|
syntax region mustacheVariableUnescape matchgroup=mustacheMarker start=/{{{/ end=/}}}/ containedin=@htmlMustacheContainer
|
||||||
|
syntax region mustacheSection matchgroup=mustacheMarker start='{{[#/]' end=/}}/ containedin=@htmlMustacheContainer
|
||||||
|
syntax region mustachePartial matchgroup=mustacheMarker start=/{{[<>]/ end=/}}/
|
||||||
|
syntax region mustacheMarkerSet matchgroup=mustacheMarker start=/{{=/ end=/=}}/
|
||||||
|
syntax region mustacheComment start=/{{!/ end=/}}/ contains=Todo containedin=htmlHead
|
||||||
|
|
||||||
|
|
||||||
|
" Clustering
|
||||||
|
syntax cluster mustacheInside add=mustacheVariable,mustacheVariableUnescape,mustacheSection,mustachePartial,mustacheMarkerSet
|
||||||
|
syntax cluster htmlMustacheContainer add=htmlHead,htmlTitle,htmlString,htmlH1,htmlH2,htmlH3,htmlH4,htmlH5,htmlH6,htmlLink,htmlBold,htmlUnderline,htmlItalic
|
||||||
|
|
||||||
|
" Hilighting
|
||||||
|
" mustacheInside hilighted as Number, which is rarely used in html
|
||||||
|
" you might like change it to Function or Identifier
|
||||||
|
HtmlHiLink mustacheVariable Number
|
||||||
|
HtmlHiLink mustacheVariableUnescape Number
|
||||||
|
HtmlHiLink mustachePartial Number
|
||||||
|
HtmlHiLink mustacheSection Number
|
||||||
|
HtmlHiLink mustacheMarkerSet Number
|
||||||
|
|
||||||
|
HtmlHiLink mustacheComment Comment
|
||||||
|
HtmlHiLink mustacheMarker Special
|
||||||
|
HtmlHiLink mustacheError Error
|
||||||
|
HtmlHiLink mustacheInsideError Error
|
||||||
|
|
||||||
|
syn region mustacheScriptTemplate start=+<script [^>]*type *=[^>]*text/mustache[^>]*>+
|
||||||
|
\ end=+</script>+me=s-1 keepend
|
||||||
|
\ contains=mustacheError,mustacheInsideError,mustacheVariable,mustacheVariableUnescape,mustacheSection,mustachePartial,mustacheMarkerSet,mustacheComment,htmlHead,htmlTitle,htmlString,htmlH1,htmlH2,htmlH3,htmlH4,htmlH5,htmlH6,htmlTag,htmlEndTag,htmlTagName,htmlSpecialChar,htmlLink,htmlBold,htmlUnderline,htmlItalic
|
||||||
|
|
||||||
|
let b:current_syntax = "mustache"
|
||||||
|
delcommand HtmlHiLink
|
Loading…
Reference in New Issue