Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programs to Compile HTML from a Template

I'm working on a website that just uses HTML, CSS, and JS (no backend needed). It's a simple site whose main purpose is to present information. I have one standard template for all the pages (header, area for content, footer). Right now, I have to copy and paste it into each page and update any changes to it manually on a page by page basis.

Are there any good programs out there that will allow me to:

  • set a template
  • write the content code for each page separately
  • compile each page by inserting the content into the template (at a specified point)
  • output the compilation into a third file

Bonus points for something that works similar to SASS where I can have the program watch a directory for changes and auto-compile files into another directory.

Bonus points for something that allows me to add in content at multiple sections.

I want to reiterate- I do not want to use a backend language (such as PHP or Django) that would stitch the pages together on the fly. The site I'm working on doesn't need that, and it would negatively affect performance and maintainability.

like image 450
jtfairbank Avatar asked Jul 24 '12 20:07

jtfairbank


1 Answers

Look at google closure templates https://developers.google.com/closure/templates/docs/helloworld_java

It takes soy files (templates) as input, then you can pass in whatever data you want and it'll merge the template with the data, generating the HTML.

You could also use PHP from the command line to generate the HTML http://php.net/manual/en/features.commandline.php

like image 188
Juan Mendes Avatar answered Nov 10 '22 18:11

Juan Mendes