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

Multiline string: CarriageReturn + LineFeed (CRLF) problem #12

Open
J-Setzer opened this issue Jul 4, 2018 · 4 comments
Open

Multiline string: CarriageReturn + LineFeed (CRLF) problem #12

J-Setzer opened this issue Jul 4, 2018 · 4 comments

Comments

@J-Setzer
Copy link

J-Setzer commented Jul 4, 2018

My docx-Template contains the placeholder [[brief.anschrift]] which should be replaced by a multiline string:

Line 1
Line 2
Line 3
Line 4

The array passed to the $templator->render(...) function looks like this:

$values = array(
    'brief' => array( 'anschrift' => "Line1\r\nLine2\r\nLine 3\r\nLine 4" )
);

As a result, the placeholder [[brief.anschrift]] has been replaced by...

Line1 Line2 Line 3 Line 4

I have also tried several variations with single quotes ', double quotes ", CRLF within code, \r and \n as you can see here:

$values = array(
    'letter' => array(
        'address_1' => "Line1\r\nLine2\r\nLine 3\r\nLine 4"
        , 'address_2' => 'Line1\r\nLine2\r\nLine 3\r\nLine 4'
        , 'address_3' => "Line1
 Line2
 Line 3
 Line 4"
        , 'address_4' => "Line1\rLine2\rLine 3\rLine 4"
        , 'address_5' => "Line1\nLine2\nLine 3\nLine 4"
        , 'address_6' => "Line1<br>Line2<br>Line 3<br>Line 4"
 ));

For testing purposes the docx-Template contains the following placeholders:

image

And this is the result:

image

None of them returns the expected result. Am I missing something?

Question:
How can I pass a multi-line string containing CRLF?

@shadz3rg
Copy link
Owner

shadz3rg commented Jul 5, 2018

@J-Setzer Confirmed bug, i will fix this soon.

@infisoft
Copy link

It fixed? It is possible to put line break into tag content?

@duxabilii
Copy link
Contributor

Multi line strings could be created from arrays:

$values = array(
    "Line1",
    "Line2",
    "Line3",
    "Line 4"
);

In template (on new line) you can use list extension:

[[values:listitem()]]

@tventos
Copy link

tventos commented Mar 6, 2019

Sorry, but how can I put br in the table?

My template:
default

Output:
2

Thanks

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

5 participants