Answer the question
In order to leave comments, you need to log in
Parsing html and code replacement, where to dig?
Hello! Such a situation: I use gulp in my projects (standard tools: jade, scssm, concat, browser-sync, minify, etc.).
There was a task: you need a plugin, or something, that would run through all the folders in a certain directory and process only html files, and find certain given pieces of code in them and change them to certain given other pieces of code and overwrite html files with already changed pieces of code (or spit them out somewhere separately). I suspect that such a plugin should be under gulp, but I can't figure out the abundance of plugins and the often modest description of them.
And the second question: I understand that it is possible to implement such parsing stupidly through the nodejs console? At the same time, indicating pieces of code to be replaced in the console. Or am I wrong and this is the wrong step? But for this it is already necessary to write your own module specifically for the Node, as far as I understand.
To summarize: you need to go through all the specified folders, find each .html, find the given pieces of code in it (for example:
<script src="old.js></script> <a href=http://oldlink.com"></a>
) and replace them with another code (<script src="NEW.js></script> <a href=http://NEWlink.com">
, respectively). Answer the question
In order to leave comments, you need to log in
It would be better if you wrote what you have for os. Without gulp, sed would solve the problem for you.
Google search for "gulp sed" brings up the first https://github.com/lazd/gulp-replace
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question