Parse links on an HTML file, replacing variables with values.
======================
In this example, we will replace all variables with their respective values, set in the config.json.
<a href="#{first-link}">First link</a>
<a href="#{second-link}">Any other link</a>
<img src="#{highlight-image}" alt="This is my Awesome image!">
<p>#{cool-text}</p>
The config.json file for this example would look like this:
{
"file_name": "index.html",
"links": [
{ "first-link" : "http://www.google.com" },
{ "second-link" : "http://nodejs.org" },
{ "highlight-image" : "http://lorempixel.com/400/200/animals" },
{ "cool-text" : "Lorem ipsum dolor sit amet, consectetur adipisicing elit." }
]
}
Don't forget to change the value of the "file_name" key!!
======================
- Download the .zip file from github
- Extract it anywhere you want
- Copy the html file that you want to replace the variables into the root of the folder you have extracted it
- Configure the file_name and the links variable keys in the config.json
- Run the command node parse.js from your prompt/terminal
- That's it! Your parsed file will be placed at the output folder
======================
The only requirement is that you have node.js installed on your system.
======================
Leave your comments, doubts, opinions! Thanks for using it!
Made with ♥ by Alessandro Dias.