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

add ability to work with loop-index in FOR-Loops #161

Closed
wants to merge 3 commits into from

Conversation

devtim123
Copy link

Hey Guillermo, i needed to add the possibility to use the index of a FOR-loop in my templates, e.g. to display different stuff for % modulo. For using this you just have to add the suffix "Index" to your defined variable. I also edit the readme for using this.

maybe you find this also helpful.

Beste regards, tim

@coveralls
Copy link

Coverage Status

Coverage increased (+0.009%) to 92.388% when pulling a04e5cf on devtim123:master into d0d21ee on guigrpa:master.

@devtim123
Copy link
Author

i also altered the way new lines get inserted into the doc, solving the issue #143

solved by inspecting the diff from rendered document.xml with docx-template and the word-docx version. it looks like you cant add <w:br/> tags into <w:t xml:space="preserve">, wrong example:

<w:r>
   <w:t xml:space="preserve">
      You need to sit down and sketch more fucking ideas
      <w:br/>
      because stalking your ex on facebook isn’t going to get you anywhere.
   </w:t>
</w:r>

It has to be inside <w:r> tag, like this correct example:

<w:r>
   <w:t xml:space="preserve">You need to sit down and sketch more fucking ideas</w:t>
</w:r>
<w:r>
   <w:br/>
   <w:t xml:space="preserve">because stalking your ex on facebook isn’t going to get you anywhere.</w:t>
</w:r>

@jjhbw
Copy link
Collaborator

jjhbw commented Aug 16, 2023

This PR is a bit before my time, but this is great work. It turns out that we had something like this under the hood all along, so I just merged that instead, see PR #323 . Thanks a lot for your effort, though, and sorry it took so long to reply to this.

@jjhbw jjhbw closed this Aug 16, 2023
@davidjb
Copy link
Contributor

davidjb commented Aug 16, 2023

@jjhbw Something like this would be handy for referencing nested loops indexes (e.g. $personIdx to align with current $idx naming), and that'd solve the limitation of just having $idx. The existing $idx should be kept as well so an editor doesn't need to be explict - which helps with simple loops, moving code around in a document, or when the loop variable name get changed etc.

@jjhbw
Copy link
Collaborator

jjhbw commented Aug 17, 2023

@davidjb makes sense. Can you open a feature request issue to further discuss that? We can probably build on top of this PR.

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

Successfully merging this pull request may close these issues.

None yet

4 participants