Reputation: 799
I use express and pug when I inject a text var in my pug file they did not have any return line. While the string contains many \n. So how to replace line return by br in pug ?
this is my var injection :
myTextString=
`
Hey
I'm
A String
`;
this.res.render('./membres/DisplayMember', { candidature:myTextString});
and here is my pug code :
p(style="text-align:justify")=candidature
and that my output:
<p>Hey I'm A String</p>
Upvotes: 1
Views: 346
Reputation: 10559
Pug's syntax to display raw html is !{variable}
.
Your JS:
myTextString=
`
Hey
I'm
A String
`.replace(/\n/g, '<br>');
this.res.render('./membres/DisplayMember', { candidature:myTextString});
Pug:
p(style="text-align:justify") !{candidature}
Upvotes: 1