I’m working on a system that processes Excel files, extracts data, and inserts dynamic variables into an HTML string, which is later rendered into a PDF. The backend uses a regular expression to capture a numeric value (e.g., 94), which I want to insert into the HTML as part of a description. The issue is that the variable placeholders (e.g., {{section}}
) are not being replaced with the actual value when the HTML is rendered into the PDF.
Setup:
- The regex captures the value correctly (94 in this case), but the
replacement in the HTML fails. - Here is an example of how I use the placeholder in HTML:
<p>
This area has additional special provisions that may apply to your land.
Read <a href="https://example.com/special-provisions.pdf">section {{section}} to review.</a>
</p>
In the backend code, placeholder is being replaced using a RegexMatch
function, which correctly captures the value (94) but fails to replace {{section}}
in the final output:
var description = specialProvision.Description ?? "";
foreach (var key in match.Groups.Keys)
{
var value = match.Groups[key].Value;
description = description.Replace($$$$$"""{{{{{{{{key}}}}}}}}""", value);
}
What I’ve Tried:
- Using
{{section}}
in the HTML results in the PDF displaying{{section}}
as literal text. - Increasing or decreasing the number of curly braces (
{{{{section}}}}
,
{{{{{{section}}}}}}
, etc.) doesn’t help. - The value is captured correctly by the regex (94), but the
replacement isn’t happening as expected.
Note:
- I cannot modify the backend code. The only place I can make changes is within the HTML.
Is there a known issue with curly braces and templating systems that might affect this replacement in HTML-to-PDF conversion?
You need to sign in to view this answers
Leave feedback about this