Helper that returns HTML inside each block ( c#) #532
Unanswered
shahab0105
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a handlebar template which renders html dynamically based on a data array provided, now this content sometimes spans over multiple pages and since I'm trying to generate a pdf based of this html it hides the overflowing context instead of contiuning the pdf on a new page( IText7). After spending quite sometime ive realized this can be resolved with the help of some handlebar helpers.
I am trying to add pagebreaks/page change in my handlebar template, and since these pagebreaks are going to be on every nth element (because only n elements would fit on a pdf page), id need a helper that returns html on every nth index inside an each loop. I've gotten somewhat close, here the helper
and using it inside an each would be
The only problem is that it escapes the html while i would want to inject html. Trying writer.WriteSafeString("
") would yield an error because writesafestring based helper cant be used inside an each block helper for some reason (came to this conclusion because thewritesafestring helper would work outside of each block). ps i already have css for pageBreak class in my template so just adding an empty element with that class would add these pagebreaks for me
for anyone curious this css results in a pagebreak
Can anyone guide me how to create a helper in c# that returns html and would work inside an each block?
Beta Was this translation helpful? Give feedback.
All reactions