This parser acts like a templating enegine i.e. we can modularize the html components and include them in other html files as required. Once it is fed to the parser, it would generate the final html file which would have:
- All the included sub components,
- Inlined styles so as to be supported by all the mail clients
- Prettified final code.
e.g: Let's say we have a sample.html
file and a child.html
which the sample.html
imports inside it.
- The way to include it properly for the parser is by placing all the reusable components inside the
src/html/components
folder and the actual parent files in thesrc/html
folder. - Then, we include the child components in the parent component with the code
${include ./components/child.html}$
in thesample.html
file (Note:${include }$
is case-sensitive and the include statement should be closed properly with a '$' - Feed the
sample.html
file to parser and you are good to go 🎉
Firing up the parser is pretty simple:
- Open a terminal and clone this repo.
- Run
npm start
to fire up the parser. For the first time users, it would install few dependencies that this parser needs and you are ready to go.
- There are three directories inside the
src
folder namelyhtml
,stylesheet
&output
.html
- All the input html files should be placed here. We should use the files placed here as an input to the parser.stylesheet
- The stylesheet that is used by all the components (main & sub) should be placed here. Aas of now, the parser only suupports a single global stylesheet.output
- This is the folder where the parsed files will be placed into.
- Once you start the parser, you will be prompted to enter a file name(relative path to the cloned directory). NOTE: You can also add multiple files for batch conversions.
- Hit Enter.. And it's done. If successful, your parsed file will be placed inside
src/output
directory.