atom-jinja2 icon indicating copy to clipboard operation
atom-jinja2 copied to clipboard

File type detection for html

Open rogerbinns opened this issue 8 years ago • 4 comments

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.

rogerbinns avatar Dec 02 '15 01:12 rogerbinns

+1 It is not very helpful to highlight only "extends" files, as not many of them actually contain this code...

JacobCZ avatar Dec 06 '15 13:12 JacobCZ

@rogerbinns @JacobCZ Not sure it helps you guys, but I recently encountered problems with detecting jinja html for files that end in .jinja2. I added this to my config.cson:

core:
    customFileTypes:
      'text.html.jinja': [
        'jinja2'
      ]

profsmallpine avatar Dec 15 '16 18:12 profsmallpine

I did this so that HTML (.html) file itself is picked up by atom-jinja2:

  core:
    customFileTypes:
      "text.html.jinja": [
        "html"
      ]

neurobin avatar Jun 23 '17 13:06 neurobin

Hi,

I tried adding

core: customFileTypes: "text.html.jinja": [ "html" ]

it works but I dont have html syntax error highlighting anymore for html files , any idea how to have both ?

hefayed avatar Sep 25 '19 18:09 hefayed