Git Product home page Git Product logo

qutem's Introduction

About qutem

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.

Why?

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.

Getting started as user

Downloads

You can download the latest release from here: https://github.com/sasuw/qutem/releases

Installing

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).

Usage and functionality

There are two things qutem can do:

  1. replace placeholders with file contents (i.e. inserting files into files)
  2. create multiple files from one content file and one template file, e.g. for different languages

1. Inserting files into files

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.

Example

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>

2. Create multiple files from one content file and one template file

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".

Getting started as developer

Prerequisites

Dart is installed. See https://dart.dev/get-dart

Project structure

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.

Create executable

dart pub get
dart compile exe bin/qutem.dart -o bin/qutem

Running the code

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.

Miscellaneous

Contributing

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:

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Built With

License

Distributed under the MIT License. See LICENSE for more information.

qutem's People

Contributors

sasuw avatar

Stargazers

 avatar

Watchers

 avatar

qutem's Issues

In qutem output distinguish the changed placeholders from unchanged placeholders

Now the output is like this

qutem finished in 0.022 s. Replaced 0 file placeholders and 80 placeholders, creating 3 files.

also when the placeholder content has not changed. If performance-wise sensible, change it to

qutem finished in 0.022 s. Replaced 0 file placeholders (leaving n file placeholders intact) and 3 placeholders (leaving m placeholderes intact), creating 3 files.

Add support for variables

Being able to specify global variables in a qutem.var file or file-specific variables in a [filename].var would be great.

$var=value

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.