Please find attached a patch with two small fixes to the djangohtml related
runtime files:
1. improve filetype detection of "htmldjango", by also looking for "load"
block tags
2. allow optional block tag content with the opening "{% comment %}" tag.
Branch on Github: https://github.com/blueyed/vim/compare/fix-django-runtime
Online patch: https://github.com/blueyed/vim/compare/fix-django-runtime.patch
Regards,
Daniel.
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
>From 6bd456c4d551b7c8742b4a45f78f163e6764eb3a Mon Sep 17 00:00:00 2001
From: Daniel Hahler <[email protected]>
Date: Fri, 4 Jul 2014 12:43:47 +0200
Subject: [PATCH 1/2] Look for `load` blocks when detecting ft=htmldjango
---
runtime/filetype.vim | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/runtime/filetype.vim b/runtime/filetype.vim
index 17f0257..5cf3e24 100644
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -864,7 +864,7 @@ func! s:FThtml()
setf xhtml
return
endif
- if getline(n) =~ '{%\s*\(extends\|block\)\>'
+ if getline(n) =~ '{%\s*\(extends\|block\|load\)\>'
setf htmldjango
return
endif
--
1.9.3
>From 6a896b78f85bf9675f9effcd191a8770a506c054 Mon Sep 17 00:00:00 2001
From: Daniel Hahler <[email protected]>
Date: Fri, 4 Jul 2014 12:45:12 +0200
Subject: [PATCH 2/2] django: allow optional note with `{% comment %}` blocks
While the documentation has `{% comment "Optional note" %}` as an
example, the quotes appear to be optional.
Ref: https://docs.djangoproject.com/en/dev/ref/templates/builtins/#comment
---
runtime/syntax/django.vim | 2 +-
runtime/syntax/htmldjango.vim | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/runtime/syntax/django.vim b/runtime/syntax/django.vim
index 04abcc9..6e8273f 100644
--- a/runtime/syntax/django.vim
+++ b/runtime/syntax/django.vim
@@ -64,7 +64,7 @@ syn region djangoTagBlock start="{%" end="%}" contains=djangoStatement,djangoFil
syn region djangoVarBlock start="{{" end="}}" contains=djangoFilter,djangoArgument,djangoVarError display
" Django template 'comment' tag and comment block
-syn region djangoComment start="{%\s*comment\s*%}" end="{%\s*endcomment\s*%}" contains=djangoTodo
+syn region djangoComment start="{%\s*comment\(\s\+.\{-}\)\?%}" end="{%\s*endcomment\s*%}" contains=djangoTodo
syn region djangoComBlock start="{#" end="#}" contains=djangoTodo
" Define the default highlighting.
diff --git a/runtime/syntax/htmldjango.vim b/runtime/syntax/htmldjango.vim
index 4b13863..1db0f9e 100644
--- a/runtime/syntax/htmldjango.vim
+++ b/runtime/syntax/htmldjango.vim
@@ -28,7 +28,7 @@ syn cluster djangoBlocks add=djangoTagBlock,djangoVarBlock,djangoComment,djangoC
syn region djangoTagBlock start="{%" end="%}" contains=djangoStatement,djangoFilter,djangoArgument,djangoTagError display containedin=ALLBUT,@djangoBlocks
syn region djangoVarBlock start="{{" end="}}" contains=djangoFilter,djangoArgument,djangoVarError display containedin=ALLBUT,@djangoBlocks
-syn region djangoComment start="{%\s*comment\s*%}" end="{%\s*endcomment\s*%}" contains=djangoTodo containedin=ALLBUT,@djangoBlocks
+syn region djangoComment start="{%\s*comment\(\s\+.\{-}\)\?%}" end="{%\s*endcomment\s*%}" contains=djangoTodo containedin=ALLBUT,@djangoBlocks
syn region djangoComBlock start="{#" end="#}" contains=djangoTodo containedin=ALLBUT,@djangoBlocks
let b:current_syntax = "htmldjango"
--
1.9.3