VFK / gulp-html-replace

Replace build blocks in HTML. Like useref but done right.
MIT License
221 stars 31 forks source link

Add custom tag option #53

Open lucipacurar opened 8 years ago

lucipacurar commented 8 years ago

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!

VFK commented 8 years ago

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?

lucipacurar commented 8 years ago

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

lucipacurar commented 8 years ago

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

lucipacurar commented 8 years ago

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.