From 9b4e623c3c1ebb1a1af67a15579010c6d1933d74 Mon Sep 17 00:00:00 2001 From: Eric Lapouyade Date: Sat, 16 Apr 2022 12:18:07 +0200 Subject: [PATCH] Add documentation for jinja-like comments in templates --- docs/index.rst | 11 +++++++++++ tests/comments.py | 2 +- .../templates/{comments.docx => comments_tpl.docx} | Bin 3 files changed, 12 insertions(+), 1 deletion(-) rename tests/templates/{comments.docx => comments_tpl.docx} (100%) diff --git a/docs/index.rst b/docs/index.rst index df937f3..99c956a 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -121,6 +121,17 @@ But use this instead in your docx template :: This syntax is possible because MS Word considers each line as a new paragraph and ``{%p`` tags are not in the same paragraph in the second case. +Comments +........ + +You can add jinja-like comments in your template :: + + {#p this is a comment as a paragraph #} + {#tr this is a comment as a table row #} + {#tc this is a comment as a table cell #} + +See tests/templates/comments_tpl.docx for an example. + Multiple rendering .................. diff --git a/tests/comments.py b/tests/comments.py index 1aef50b..5a214ca 100644 --- a/tests/comments.py +++ b/tests/comments.py @@ -1,6 +1,6 @@ from docxtpl import DocxTemplate -tpl = DocxTemplate('templates/comments.docx') +tpl = DocxTemplate('templates/comments_tpl.docx') tpl.render({}) tpl.save('output/comments.docx') diff --git a/tests/templates/comments.docx b/tests/templates/comments_tpl.docx similarity index 100% rename from tests/templates/comments.docx rename to tests/templates/comments_tpl.docx