I want to merge one HTML file into another. Not just include it, but merge.
Example
master.html:
<!DOCTYPE html>
<html>
<head>
<title>My cat</title>
</head>
<body>
<h1>My cat is awesome!</h1>
</body>
</html>
_index.html:
<!DOCTYPE html>
<html>
<body>
<p><img src="cat.jpg"/></p>
</body>
</html>
Now I merge _index.html into master.html.
$ html_merge master.html _index.html > result.html
result.html
<!DOCTYPE html>
<html>
<head>
<title>My cat</title>
</head>
<body>
<h1>My cat is awesome!</h1>
<p><img src="cat.jpg"/></p>
</body>
</html>
html_merge
is a script what I'm looking for. I'll use it for building static websites.
I would like to use Ruby, but it's not required.
Update
I don't want to reinvent yet another template language. There is a lot of template languages with include
/yield
statement and partials support. Liquid, mustache and so on. I use them for different tasks. Now I need to merge HTML files, nothing more.