[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/jinja2-mode a99762e050 06/57: Add end tag command
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/jinja2-mode a99762e050 06/57: Add end tag command |
Date: |
Mon, 17 Jan 2022 05:58:22 -0500 (EST) |
branch: elpa/jinja2-mode
commit a99762e050e6ff75f9e6ec226b06b2b1ca7d2d10
Author: Florian Mounier <florian.mounier@kozea.fr>
Commit: Florian Mounier <florian.mounier@kozea.fr>
Add end tag command
---
jinja2.el | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/jinja2.el b/jinja2.el
index ec8e20dfe6..793f6613e9 100644
--- a/jinja2.el
+++ b/jinja2.el
@@ -75,6 +75,38 @@
"json" "percent_format" "person_title"
"mail_format" "sort_by" "split"))
+(defun jinja2-html-find-open-tag ()
+ "Return open tag for closed template tag.
+
+If tags are unbalanced, raise error."
+ (if (search-backward-regexp
+ (rx "{%"
+ (* whitespace)
+ (? (group
+ "end"))
+ (group
+ (* word))
+ (group
+ (*? anything))
+ (* whitespace)
+ "%}") nil t)
+ (if (match-string 1)
+ (if (not (string= (match-string 2) (jinja2-html-find-open-tag)))
+ (error "Unmatched Jinja tag")
+ (jinja2-html-find-open-tag))
+ (match-string 2))
+ nil))
+
+(defun jinja2-html-close-tag ()
+ "Close the previously opened template tag."
+ (interactive)
+ (let ((open-tag (save-excursion (jinja2-html-find-open-tag))))
+ (if open-tag
+ (insert
+ (format "{%% end%s %%}"
+ open-tag))
+ (error "Nothing to close"))))
+
(defconst jinja2-font-lock-comments
`(
(,(rx "{#"
- [nongnu] branch elpa/jinja2-mode created (now 03e5430a7e), ELPA Syncer, 2022/01/17
- [nongnu] elpa/jinja2-mode 151ec725c6 01/57: Import of jinja2 mode, previous history in http://github.com/paradoxxxzero/zerorc/blob/master/.emacs.d/elisp/jinja2.el, ELPA Syncer, 2022/01/17
- [nongnu] elpa/jinja2-mode 1a3c2bf239 02/57: Add readme, ELPA Syncer, 2022/01/17
- [nongnu] elpa/jinja2-mode a99762e050 06/57: Add end tag command,
ELPA Syncer <=
- [nongnu] elpa/jinja2-mode 1d911c9b73 12/57: Great improvement of close-tag, ELPA Syncer, 2022/01/17
- [nongnu] elpa/jinja2-mode e34a8f46df 31/57: follow header conventions, ELPA Syncer, 2022/01/17
- [nongnu] elpa/jinja2-mode 0200889436 11/57: Add elc .gitignore, ELPA Syncer, 2022/01/17
- [nongnu] elpa/jinja2-mode d75353d070 18/57: indent by default with sgml indent setting, ELPA Syncer, 2022/01/17
- [nongnu] elpa/jinja2-mode f91984ab79 43/57: Merge pull request #11 from akheron/patch-1, ELPA Syncer, 2022/01/17
- [nongnu] elpa/jinja2-mode fddbfce7a3 07/57: Add tag closure, ELPA Syncer, 2022/01/17
- [nongnu] elpa/jinja2-mode c262cace36 16/57: Add missing autoload, ELPA Syncer, 2022/01/17
- [nongnu] elpa/jinja2-mode bc7365c60a 29/57: Forgot a dash, ELPA Syncer, 2022/01/17
- [nongnu] elpa/jinja2-mode a9e7220486 48/57: add j2 extension, ELPA Syncer, 2022/01/17
- [nongnu] elpa/jinja2-mode 29b492f175 49/57: Merge pull request #14 from mmckinst/j2_extension, ELPA Syncer, 2022/01/17