bake is a mighty template engine for static text files. It is something like
Tom Preston-Werner's jekyll, but is independent of file
types and markup languages.
bake enables JavaScript templates for any type of text files. These
templates may contain embedded JavaScript as a template language.
Example
A template (default.tpl
) may look like this:
<!DOCTYPE html>
<html lang="<%= lang %>">
<head>
<meta charset="utf-8">
<title><%= title %> | <%= siteTitle %></title>
</head>
<body>
<h1><%= title %></h1>
<%= __content %>
<% if (has('foo')) { %>
<p>Foo is defined.</p>
<% } %>
</body>
</html>
And a corresponding content file (post.txt
) could look like this:
title: A sample file
lang: en
<p>Sample text.</p>
With a minimal configuration object
{
"fileExtensions": {
"txt": "html"
},
"properties": {
"siteTitle": "My Site"
}
}
the output (post.html
) would be:
<!DOCTYPE>
<html lang="en">
<head>
<meta charset="utf-8">
<title>A sample file | My Site</title>
</head>
<body>
<h1>A sample file</h1>
<p>Sample text.</p>
</body>
</html>
bake not only enables building websites (although that's its main purpose)
but lets you choose. You can write hooks for each property to control the
output.
Visit the Wiki for more information or look at the example.
What this is not
bake is not a webserver. It doesn't replace your Apache/Nginx etc. So if you
want to write a website that is accessible by the public, you have to change the
settings of your webserver to use bakeDir
as the root directory.
bake is no blogging engine (although it's possible to create one with the
help of bake). It doesn't provide generating an index or a feed. It doesn't
have any commenting functionality either. If you are looking for a system with
these features, try bread which is based on bake.
Bugs and Issues
If you encounter any bugs or issues, feel free to open an issue at
github.
License
This package is licensed under the MIT license.
Credits
This work was inspired by heimweh by Benjamin Birkenhake and
txtracer by Konstantin Weiss, but also by
wheat by Tim Caswell and jekyll by Tom
Preston-Werner.