-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
New line with templateProcessor #1322
Comments
+1 |
Hi, Any news about it ? Thanks |
+1 |
+1 |
+1, any news ? |
Did anyone came up with a fix or workaround for this already? |
Since I need this urgently I came up with a dirty workaround for this problem. As I see it the exact problem is the following:
Yet, output escaping uses I tried to fix this problem in Phpword/Escaper/Xml.php: There I changed the function
TO:
So after the input is escaped with htmlspecialchars I simply revert these changes for the newlines. Not very elegant but does the job for now. |
Any news on this issue? |
I'm also interested by having a cleaner solution ! Some news ? |
Same issue
|
+1 |
help please, +1 |
+1 |
1 similar comment
+1 |
Here is my solution:
I hope it helps. |
I added </w:t><w:p/><w:t> for a new paragraph and it is working well. Here is the templatewords and printscreen of the word document: ${alternatif_block} Here is the codes:
And here is the printscreen of output: |
But it works for only at first paragraph... |
For you this code works in all breaks or for just the first? |
It replaces all ${newline} not only the first one. |
@damienlaguerre tks for the quickly reply. I'll look why for me replace just the first. |
Unless I'm missing something, it seems that However, this is not documented clearly in neither https://phpword.readthedocs.io/en/latest/templates-processing.html#setcomplexvalue nor https://phpword.readthedocs.io/en/latest/templates-processing.html#setvalue, and therefore it's not obvious if this is by design or a missing feature (or even a bug). @troosan, can you comment on this? As a (temporary) workaround, I'm using something along the lines of $newline = new PreserveText('</w:t><w:br/><w:t>');
while (isset($templateProcessor->getVariableCount()['newline'])) {
$templateProcessor->setComplexValue('newline', $newline);
} to replace |
#2038 has been labeled “WontFix”. |
I'm not sure why the solution using setComplextValue with PreserveText doesn't work for me. I have to use cloneBlock to generate lines. Here is my solution:
$replacements = [
['line' => 'line 1 text'],
['line' => 'line 2 text'],
...
];
$templateProcessor->cloneBlock('lines', 0, true, false, $replacements); |
+1 for me. |
This is:
Expected Behavior
$myString = "Test-X \n Test-Y"
`Test-X'
'Test-Y'
Current Behavior
$myString = "Test-X \n Test-Y"
`Test-XTest-Y'
#838
<w:br/>\n
and</w:t><w:br/><w:t>
don't work. the problem is the same.Failure Information
When I use the template processor, I can't insert a new line with a string.
How to Reproduce.
Context
The text was updated successfully, but these errors were encountered: