GithubHelp home page GithubHelp logo

atom-jinja2's Introduction

Atom Jinja2 package

Provides syntax highlighting for jinja2 templates in atom.

Adds a "jinja templates" syntax and several combined syntax definintions, for jinja templates which output different types of file.

New Syntax Definintions

In addition to the file extensions below, all syntax definintions also specify .jinja2 & .j2.

"HTML (Jinja templates)" syntax

Jinja templates for HTML files. Also matches .html.j2

"Generic Config (Jinja Templates)" syntax

Jinja templates for Config files. Also matches .conf.j2.

Requires the language-generic-config package.

"Python (Jinja Templates)" syntax

Jinja templates for Python files. Also matches .py.j2

"Shell Script (Jinja Templates)" syntax

Jinja templates for Shell Script files. Also matches .sh.j2

"XML (Jinja Templates)" syntax

Jinja templates for XML files. Also matches .xml.j2

"YAML (Jinja Templates)" syntax

Jinja templates for YAML files. Also matches .yml.j2 & .yaml.j2

atom-jinja2's People

Contributors

danielchatfield avatar dflock avatar ericsysmin avatar oleksandr-kuzmenko avatar raz0rwire 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

Watchers

 avatar  avatar

atom-jinja2's Issues

Also .j2 extension

I (and some others) use .j2 for a jinja2 extension, and it would be convenient if those were included in this package.

Thanks & Cheers

can you add...

I use the Django web framework and it uses Jinja2 template tags inside basic html files... can you please add the ability for your add on to recognize jinja template tags (the {{ }} and {% %} and the keywords contained within them)

Thanks

Chris

Release?

It's been a while since a release and there are few pending changes that would be useful to have (like jinja as one of the associated fileTypes). Do you have any intention of releasing an update soon?

Line statements

Is there any way to configure the package to use custom line statements?

i.e.: we use the % sign for line statements.

I tried playing around with the .cson file and change regexes but I couldn't find a way for atom to actually take them into consideration (sorry, noob question I guess...)

Failed to load a atom-jinja2 package grammar

[Enter steps to reproduce:]

  1. ...
  2. ...

Atom: 1.48.0 x64
Electron: 5.0.13
OS: Microsoft Windows 10 Pro
Thrown From: atom-jinja2 package 0.6.0

Stack Trace

Failed to load a atom-jinja2 package grammar

At C:\Users\Joel\.atom\packages\atom-jinja2\grammars\html (jinja templates).cson: reserved word 'static' in C:\Users\Joel\.atom\packages\atom-jinja2\grammars\html (jinja templates).cson

[stdin]:21:9: error: reserved word 'static'
{% load static %}
        ^^^^^^
  at /packages/atom-jinja2/grammars/html (jinja templates).cson:1:1

Commands

Non-Core Packages

atom-beautify 0.33.4 
atom-jinja2 0.6.0 
atom-live-server 2.3.0 
busy-signal 2.0.1 
emmet 2.4.3 
file-icons 2.1.41 
intentions 1.1.5 
linter 2.3.1 
linter-jscs 4.2.4 
linter-jshint 3.1.19 
linter-ui-default 1.8.1 
minimap 4.29.9 
pigments 0.40.2 
python-autopep8 0.1.3 
script 3.26.0 
todo 0.6.0 

Support for .json.j2

I use this extensively for Ansible/AWS configuration and JSON + J2 would be a huge help.

File type detection for html

It looks like the only way a jinja2 html file is detected is by extends in the first line. Very few of my templates have that, making having to manually select the mode a big pain for each and every file (it isn't remembered across atom restarts).

In theory some heuristics would help, but it seems like many template engines use similar punctuation. Perhaps you could also add comment detection - eg \{#.*jinja2.*#\} which I can add to all my templates.

At the very least it would be helpful documenting how the detection is done.

support for file format based on shebang header

It would be very useful to enable file format detection based on shebang lines. Here are few examples:

#!/bin/bash ...
#!/bin/sh ...
(shell)

#!/usr/bin/env ansible-playbook -i ../hosts -K
(yaml)

#!/usr/bin/env python
#!/usr/bin/env python2
#!/usr/bin/env python3
#!/usr/bin/env python2.7
(python)

References

Simplify settings and file extensions

Jinja does not have a standard file extension, so wouldn't it make sense to just use the file extensions that jinja would be used in by context.

For example, you'll be using markdown, xml, or html files which would be the common types. The jinja docs also specify that you can use j2 or jinja even though they are arbitrary by definition.

The settings are also nothing more than duplicate settings as well even though they all use the same configuration. It makes the first glance look overwhelming and cumbersome even though it's fine and you only need to edit the initial settings.

I use html for my html templates and found it strange that it didn't work out of the box. Looked at the package source and modified the array by adding it and it worked.

HTML syntax highlighting not working on .j2 files.

When I first installed the Atom module I changed all my template files from .html to .j2 so that the package would work. Now after updating I find that only Jinja specific commands are highlighted, while the bulk of the html code gets no highlighting.

syntax highlighting for YAML (Jinja Templates) broken

Since some of the less recent Atom and/or package updates, syntax highlighting for Jinja2 elements seems to be broken.

I allready filed a nearly identical issue here JonGretar/language-salt#8, but could confirm the issue is wthin atom-jinja2 (using "YAML (Jinja Templates)" directly.

Atom 1.14.2 on macOS 10.12.3 (16D32)
language-yaml 0.28.0
atom-jinja2 0.6.0

What it looks like:

bb9dd11c-b007-11e6-8433-418193896b7b

What Jinja2 should look like (works in only in some situations):

e969dabe-b007-11e6-8bca-ba51967ab715

Original code example (SaltStack SLS file):

# pkg.latest
# service.running

httpd:
  pkg:
    - installed
    {% if grains['os'] == 'RedHat' or grains['os'] == 'Fedora' or grains['os'] == 'CentOS' %}
    - name: httpd
    {% elif grains['os'] == 'Debian' or grains['os'] == 'Ubuntu'%}
    - name: apache2
    {% elif grains['os'] == 'Gentoo' or grains['os'] == 'Arch' or grains['os'] == 'FreeBSD' %}
    - name: apache
    {% endif %}
  service:
    - running
    {% if grains['os'] == 'Debian' or grains['os'] == 'Ubuntu' or grains['os'] == 'Gentoo' %}
    - name: apache2
    {% endif %}
    - enable: True
    - require:
      - pkg: httpd

date > /tmp/started_apache:
  cmd:
    - wait
    - watch:
      - service: httpd

{#- Comment #}

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.