Giter Club home page Giter Club logo

lexima-template-rules's Introduction

Lexima Rules for Web Templates

Lexima is great, but does not include any rules for web templates, so I wrote some. Then I figured other people might find them useful, so I pulled them out of my init.vim and here they are.

Getting Started

Use your favorite plugin manager. I like Vim-Plug. You must have Lexima.

Behavior

In all cases below, | represents the cursor position.

For all templates, including plain HTML and XML:

Before                      Input                   After
----------------------------------------------------------------------------
|                           <                       <|>
----------------------------------------------------------------------------
<|> or <|/>                 <Backspace>             |
----------------------------------------------------------------------------
<tag>| or <tag/>|           <Backspace>             <tag|> or <tag|/>
----------------------------------------------------------------------------
<tag foo="bar"|>            /                       <tag foo="bar"/>|
----------------------------------------------------------------------------
<tag|/>                     /                       <tag/>|
----------------------------------------------------------------------------
<tag>|</tag>                <Enter>                 <tag>
                                                        |
                                                    </tag>
----------------------------------------------------------------------------

For Django, Jinja2, Twig and Liquid templates (as appropriate):

Before                      Input                   After
----------------------------------------------------------------------------
{|}                         % or #                  {%|%} or {#|#}
----------------------------------------------------------------------------
{%|%}                       -                       {%-|-%}
----------------------------------------------------------------------------
{%|%}                       <Space>                 {% | %}
----------------------------------------------------------------------------
{%-|-%}                     <Space>                 {%- | -%}
----------------------------------------------------------------------------
{%- | -%}                   <Backspace>             {%-|-%}
----------------------------------------------------------------------------
{% | %}                     <Backspace>             {%|%}
----------------------------------------------------------------------------
{%-|-%}                     <Backspace>             {%|%}
----------------------------------------------------------------------------
{%|%}                       <Backspace>             {|}
----------------------------------------------------------------------------
{{ foo| }} or {{ foo |}}    }                       {{ foo }}|
----------------------------------------------------------------------------
{{ foo }}|                  <Backspace>             {{ foo| }}
----------------------------------------------------------------------------
{% tag| %}                  %                       {% tag %}|
----------------------------------------------------------------------------
{% tag %}|                  <Backspace>             {% tag| %}
----------------------------------------------------------------------------
{% if foo %}|               <Enter>                 {% if foo %}
                                                        |
                                                    {% endif %}
----------------------------------------------------------------------------

For Mako templates:

Before                      Input                   After
----------------------------------------------------------------------------
<%def name="foo">|          <Enter>                 <%def name="foo">
                                                        |
                                                    </%def>
----------------------------------------------------------------------------
% for foo in bar:|          <Enter>                 % for foo in bar:
                                                        |
                                                    % endfor
----------------------------------------------------------------------------
<%| or <%!|                 <Enter>                 <% or <%!
                                                        |
                                                    %>
----------------------------------------------------------------------------
<%inheri|>                  t                       <%inherit|/>
----------------------------------------------------------------------------
<%namespace|/>              <Backspace>             <%namespac|>
----------------------------------------------------------------------------

Template Systems

There are rules for the following template systems:

If there are other template systems with syntax similar to that of any of the above, I will be glad to add them to these rules (or accept pull requests).

Options

In Jinja2 and Twig templates, I rarely use set blocks. By default, these rules will not add {% endset %} for you. If you want endsets added, let g:lexima_template_rules_endset = 1 in your .vimrc or init.vim.

lexima-template-rules's People

Contributors

txhawks avatar deathlyfrantic avatar

Watchers

James Cloos avatar  avatar

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.