qutem (quick template engine) is a simple template engine for creating static, internationalized websites. It runs as a single executable program on your Linux, Mac or Windows.
I could not find a simple template engine running in a terminal allowing me to replace placeholders with file contents, so I decided to create my own. A while later I wanted to create internationalized pages from a template file as well, so I added that functionality.
You can download the latest release from here: https://github.com/sasuw/qutem/releases
Unpack the tar.gz or zip file and execute qutem from your terminal or command line window. For a more permanent installation, copy qutem e.g. to /usr/local/bin (Linux/MacOS) or to C:\Windows\system32 (Windows).
There are two things qutem can do:
- replace placeholders with file contents (i.e. inserting files into files)
- create multiple files from one content file and one template file, e.g. for different languages
In the file, where you want content to be inserted, insert a snippet like this
{{!file.txt}}
and the placeholder will be replaced with the content of the file. The file path is relative to the directory where qutem is executed.
If the placeholder is within an HTML or JavaScript comment without other text content, the comment part is removed when the placeholder is substituted. This enables you to put placeholders in your files without creating errors when using the files before running qutem. See example below for a demonstration.
Suppose you have a file index.html with the following content
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Below is the title text placeholder, which qutem will replace -->
<title>{{!title.txt}}</title>
</head>
<body>
<!-- Below is the body template placeholder, which qutem will replace -->
<!--{{!body.html}}-->
</body>
</html>
and the following two files with their respective contents
title.txt:
Title of test page
body.html:
<p>This is the body</p>
You want to insert the contents of these two files into index.html where the respective placeholders are.
You run
qutem index.html
Now you have a new file dist/index.html with the following content
!DOCTYPE html>
<html lang="en">
<head>
<!-- Below is the title text placeholder, which qutem will replace -->
<title>Title of test page</title>
</head>
<body>
<!-- Below is the body template placeholder, which qutem will replace -->
<p>This is the body</p>
</body>
You have a content file containing a placeholder like this
{{placeHolder}}
and a template file with placeholder values like this
placeHolder.en=placeholder
placeholder.de=Platzhalter
placeholder.it=segnaposto
Running qutem results in three files in three directories "en", "de" and "it" containing the respective files with the string "{{placeHolder}}" replaced with "placeholder", "Platzhalter" and "segnaposto".
Dart is installed. See https://dart.dev/get-dart
Standard dart project structure created with pub, see https://dart.dev/tools/pub/package-layout
The main executable, qutem.dart is located in the bin directory. The internal libraries used by qutem are in the lib directory.
The tests are in the test directory and the test data is in the test/data directory.
dart pub get
dart compile exe bin/qutem.dart -o bin/qutem
When you are in the project root directory, you can execute
dart bin/qutem.dart
to run the program. For debugging, you can use e.g. Visual Studio Code.
You can contribute to this project in many ways:
- submitting an issue (bug or enhancement proposal)
- testing
- contributing code
If you want to contribute code, please open an issue or contact me beforehand to ensure that your work in line with the project goals.
When you decide to commit some code:
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.