Quick helper to include html using js and custom tags.
There's lot of times when you need to code a template and don't want to repeat your code in each file, like the header or footer, then, this helper helps you to test the templates using partials and later pick the template engine that's need it.
Also it works for browser extensions and plugins where performance is not an issue as big as easy maintenance
- Import the js at the end of the html file
- Add custom tag:
<partial file="partials/ongoing.html"></partial>
Due to Chrome limitation to access iframes of files on the same PC that the js is running (allowed by Firefox), we decide to go with an ajax approach to this, please keep in mind, this means that you need to run the code in an extension or server in order to make it work.
Due to the limitations you may need to launch an easy fast webserver to test, that's pretty easy, here a couple of options:
- Install the library:
sudo npm install http-server -g
- Run the server on selected folder:
http-server
- Run the server on selected folder:
python -m SimpleHTTPServer