gulp-html-replace icon indicating copy to clipboard operation
gulp-html-replace copied to clipboard

Add custom tag option

Open lucipacurar opened this issue 8 years ago • 4 comments

Hi,

I'm trying to add a way to customize "build" and "endbuild" tags inside the parser regexp, so I moved the regexp inside the Parser constructor and converted the regexp literal to a string:

this.regex = new RegExp("(\\n?)([ \\t]*)(<!--\\s*" + config.tagName + ":(\\w+(?:-\\w+)*)\\s*-->)\\n?([\\s\\S]*?)\\n?(<!--\\s*end" + config.tagName + "\\s*-->)\\n?", "ig");

Inside the regexp I just escaped the "\" character and concatenated a custom tagname. For some reason the tests fail because the output is different. Since I'm no expert in RegExp, could you please let me know if the regexp above is correct?

The fork is here: https://github.com/lucassp/gulp-html-replace

Thanks!

lucipacurar avatar Oct 18 '16 11:10 lucipacurar

Hi, Lucian. I just tried your fork and it works like a charm. Are you on windows? This might be some weird windows issue or something with line endings or encodings. It's hard to tell really. What exactly are you seeing? What's the difference between expected and actual output?

VFK avatar Oct 20 '16 17:10 VFK

Yes, I tried it on Windows. Let me try it on Mac.

lucipacurar avatar Oct 20 '16 17:10 lucipacurar

Yeap, everything works like a charm on Mac. I should probably add some tests too.

lucipacurar avatar Oct 20 '16 17:10 lucipacurar

Ok, I've added some basic tests for it. I actually made this change because we still use usemin and wiredep inside the same file, and those plugins break down when we try to use them together with gulp-html-replace.

lucipacurar avatar Oct 20 '16 18:10 lucipacurar