'Split EJS text including template in the middle

I have a long text inside a variable that is rendered through EJS:

<% var longText = 'Very long text' %>

<%- longText %>

So far, so good; works fine. The thing is that I want to split this long text in two parts and have another EJS template inserted between these parts.

How to do that?



Solution 1:[1]

Got it.

text.split("<br /><br />")
// <br /><br /> is the paragraph marker

It returns me an array with the paragraphs of my text. I then insert each element of the array (each paragraph) wherever I want, with whichever I want beteen elements.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Pedro Rabbi