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

Is repeating bullet points possible #665

Open
tomhillgreyridge opened this issue Apr 19, 2024 · 1 comment
Open

Is repeating bullet points possible #665

tomhillgreyridge opened this issue Apr 19, 2024 · 1 comment

Comments

@tomhillgreyridge
Copy link

Description

I'm trying to create a document template where a list of bullet points is created from dynamic data. The problem is that I can't find a way to do a #foreach loop which doesn't either a) put all content in one bullet point or b) end up with either extra bullet points or extra spacing

What I've Tried

Putting it into the list item like this

image

and the result was all names on one line, like this

image

I thought the solution might be to put the #end onto a new bullet point so the bullet got repeated

image

which got me closer but I end up with an additional empty bullet point for the #end merge field.

image

So I thought I'd try moving the loop outside the list item

image

but that ends up with multiple lists

image

I've then tried fiddling around with the paragraph spacing before and after in Word itself to see whether that would do it, but I can't get to the point where it looks like it would if you typed it in Word, i.e.

image

Analysis

I assume this is an issue similar to the one with table rows where the loop needs to be moved outside the LI but I can't find an option similar to the @before-row / @after-row stuff for list items. One solution I can think of (which would probably be generically useful) would be to remove an element from the generated output DOCX if the only thing in that input element is a merge field - that way you don't end up with extra elements solely because of the #foreach merge fields.

That would also solve some of the problems with merge fields creating extra white-space in the output document.

The alternative might to to implement the solution used by https://github.com/thombergs/docx-stamper which is to use comments to store the expressions rather than merge fields

Questions

  • Am I missing any obvious way to create bullet points in a loop?
  • Is there any way to avoid XDocReport creating paragraphs in the output docx for merge fields which are simply there for control flow i.e. the #foreach merge fields?
  • How might I go about making the @before-row / @after-row stuff work with list items?
@czerudla
Copy link

Hi @tomhillgreyridge, I am not sure about Velocity, but in Freemarker, you can use separator notation sep https://freemarker.apache.org/docs/ref_directive_list.html#ref_list_sep
So in yor case it will be done like this:

  • «[#list people as person]»«${person.name!}»«[#sep]»
  • «[/#list]»

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

No branches or pull requests

2 participants