alanshaw / grunt-include-replace

Grunt task to include files and replace variables. Allows for parameterised includes.
MIT License
200 stars 45 forks source link

Argument of include can't have linebreak #62

Open ghost opened 8 years ago

ghost commented 8 years ago

Now this is serious trouble for me.

What i mean is that:

@@include('templates/main_heading.tpl.html', {
    "subheader": "Subheader introduction",
})

pass ok

@@include('templates/main_heading.tpl.html', {
    "subheader": "
           Subheader introduction
           test test test
    ",
})

is not! got: Warning: Unexpected token Use --force to continue.

This is superimportant, since you can do stuff like that even:

@@include('templates/main_heading.tpl.html', {
    "content": "
        <h3>thiis is my supadupa haeding</h3>
        <div class='p'>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis.</div>
    ",
})

And everything passes perfectly good except linebreaks :\

I really hope it's fixeable (seem to be regex issue that can be overcome) If anybody can post solution immideately (before | if at all) it would be fixed with new release i would love to see it)

D-B-S commented 8 years ago

JavaScript doesn't naturally include line breaks in strings, have you tried:

"<p>Line 1</p>\r\n<p>Line 2</p>"

Or if you want to maintain the line breaks in your includes statement:

"<p>Line 1</p>\r\n" +
"<p>Line 2</p>"

(This is untested inside this plugin, it's just off the top of my head JS)