Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sub documents in bulleted list results in extra blank lines #574

Open
mehdiammar opened this issue Nov 18, 2024 · 2 comments
Open

Sub documents in bulleted list results in extra blank lines #574

mehdiammar opened this issue Nov 18, 2024 · 2 comments
Labels

Comments

@mehdiammar
Copy link

Describe the bug

If you attempt to render sub documents in a bulleted list using a for loop, an extra bullet point is added for each sub document.

To Reproduce

  1. Create a word document with any text in it, can even be a single word. This will be the sub document.
  2. Create a master template document, add a for loop to render sub docs in a bulleted list:

{% for item in list %}
a) {{ item }}{% endfor %}

  1. Try to render the template with the following code:
tpl = DocxTemplate(PATH_TO_MASTER)
sd = tpl.new_subdoc(PATH_TO_SUB_DOC)

context = {
 "list": [ sd ]
}

tpl.render(context)
tpl.save(OUTPUT_PATH)

Expected behavior

The list of sub docs should be rendered correctly.

Screenshots

1
2

@mehdiammar mehdiammar added the bug label Nov 18, 2024
@mehdiammar
Copy link
Author

mehdiammar commented Nov 18, 2024

For those facing the same issue, try:

{%p for item in list %}
a) {{ item }}{% endfor %}

@mehdiammar
Copy link
Author

I just noticed this results in my extra bullet points at the bottom of the page, seemingly disconnected from the for loop. If this could be looked at, it would be greatly appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant