Coder Social home page Coder Social logo

mustache.vim's Introduction

mustache and handlebars mode for vim

Note: This repo is deprecated, active development moved to mustache/vim-mode.

A vim plugin for working with mustache and 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.

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

This is combined work from juvenn/mustache.vim and nono/vim-handlebars.


Thanks @5long for adding matchit support.

You're encouraged to propose ideas or have discussions via github issues.

mustache.vim's People

Contributors

chrisburnor avatar juvenn avatar ktamas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

mustache.vim's Issues

Allow HTML fragments

for instance:

<tr data-id="{{id}}" class="cart-item">
  <th>{{name}}</th>
  <td>{{quantity}}</td>
</tr>

will throw a syntax error because the template doesn't have a <table> tag around it, but I'm just generating TRs for an existing table.

Consider adding this plugin to vim source

Hi @juvenn,
I think this plugin is useful enough so we can consider adding it to vim source.

Bram Molenaar seems to be pretty ok with that idea. He is openly calling for contributions like this. For example, see this syntax help section (second paragraph).

Also, here's the link to discussion where Bram seems to be ok with adding a pretty obscure (almost proprietary) syntax file to vim source.
Compared to that, I think mustache is pretty mainstream file type that a lot of people use.

Now, before we take that step, I think we should take some time, and polish this plugin before posting it on vim-dev mailing list and to vim maintainer Bram.

Here are some things I noticed:

  • there is also this relatively popular project vim-handlebars. Our project, and that one are almost the same. We might consider contacting the maintainer of that project and merge projects to a single one (for example: vim-mustache-handlebars).
    The plugin would be more useful that way, and I think that makes another good argument when submitting to vim source.
  • if not merging, vim-handlebars project had some good commits lately we could bring to our project too.
  • I think it would be possible to fix this issue

@juvenn , what do you think about these ideas?
Should we contact that maintainer of vim-handlebars and suggest merging to him?
I will start work on improving the the above suggested things over the next couple weeks.
Do you agree we should propose adding the project to vim source in the future?

Bruno

Mustache indentation

mustache.vim should know how to indent opening and closing mustache tags:

{{#items}}
  {{foo}}
{{/items}

ftdetect not working?

I installed your plugin via pathogen, and I can't have syntax highlighting in a .handlebars file unless I explicitely set the filetype (like this :setfiletype mustache). I saw a condition in the file : if has("autocmd"), so I typed :autocmd and saw it was installed, obviously, so the condition should pass.

syntactic support?

I guess this is a feature request. The syntactic html checker complains about html inside script tags. Is this the right plugin project to fix that?

Highlighting html

Awesome work guys. I am fairly new to vim and just wanted to share my install experience. At first I couldn't figure out why the plugin wasn't highlighting html. Then I found the script to set html syntax.

au BufNewFile,BufRead .mustache,.handlebars,.hbs,.hogan,.hulk,.hjs set filetype=html syntax=mustache | runtime! ftplugin/mustache.vim ftplugin/mustache_.vim ftplugin/mustache/_.vim

Maybe this could be added to the docs for beginners like me? :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.