Skip to content

Commit

Permalink
Improve django detection, closes #585
Browse files Browse the repository at this point in the history
  • Loading branch information
sheerun committed Oct 14, 2020
1 parent c45f0b8 commit ba11e0f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion autoload/polyglot/detect.vim
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ func! polyglot#detect#Html(...)
endif
for lnum in range(1, min([line("$"), 50]))
let line = getline(lnum)
if line =~# '{%-\=\s*\(end.*\|extends\|block\|macro\|set\|if\|for\|include\|trans\)\(\<\|\>\)\|{#\s\+'
if line =~# '{%-\=\s*\(end.*\|extends\|block\|macro\|set\|if\|for\|include\|trans\|load\)\(\<\|\>\)\|{#\s\+'
set ft=htmldjango | return
endif
if line =~# '\(\<\|\>\)DTD\s\+XHTML\s'
Expand Down
2 changes: 1 addition & 1 deletion heuristics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ rules:
filetype: mason
- lines: 50
rules:
- pattern: '{%-?\s*(end.*|extends|block|macro|set|if|for|include|trans)\b|{#\s+'
- pattern: '{%-?\s*(end.*|extends|block|macro|set|if|for|include|trans|load)\b|{#\s+'
filetype: htmldjango
- pattern: '\bDTD\s+XHTML\s'
filetype: xhtml
Expand Down
1 change: 1 addition & 0 deletions tests/extensions.vim
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ call TestExtension("mason", "mason2.html", "<%filter></%filter>")
call TestExtension("htmldjango", "jinja2.html", "{% for item in navigation %}{% endfor %}")
call TestExtension("htmldjango", "jinja3.html", "{% block head %}")
call TestExtension("htmldjango", "jinja4.html", "{# some comment #}")
call TestExtension("htmldjango", "jinja3.html", "{% load static %}")
call TestExtension("xhtml", "xhtml.html", "<DTD XHTML ")

" many html templates use {{ }}, e.g. Angular, we should not assume django
Expand Down

0 comments on commit ba11e0f

Please sign in to comment.