Skip to content

A command line application for compiling Jinja templates into static HTML files

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
SSE_LICENSE
Notifications You must be signed in to change notification settings

Momo8289/JinjaCompiler

Repository files navigation

JinjaCompiler

This program takes a directory containing Jinja templates, renders them, and outputs them for use in a static website.

usage: JinjaCompiler [-h] [-p PAGES_DIR] [-w] [-t TYPES] [-n] [-s] [-P PORT] templates_dir output_dir

Compile Jinja templates into static HTML files

positional arguments:
  templates_dir         Path to the directory containing the Jinja templates
  output_dir            Path where the compliled files should go. Folder structure will copy that of pages_dir. Directory contents are deleted before compiling, dont put stuff in
                        here that you want to keep.

options:
  -h, --help            show this help message and exit
  -p PAGES_DIR, --pages-dir PAGES_DIR
                        Relative path in templates_dir which contains the templates that will be compiled to HTML. Default: 'pages/'
  -w, --watch           Run in watcher mode, which will monitor templates_dir for changes and automatically recompile.
  -t TYPES, --types TYPES
                        Comma-separated list of file types that will be treated as Jinja templates. Default: .jinja
  -n, --no-copy         Don't copy non-template files into output directory.
  -s, --server          Serve the output dir with a local webserver. Does nothing without -w.
  -P PORT, --port PORT  Port the webserver will be served on.

Compiling as a standalone executable

python -m venv venv

# If on Linux
source venv/bin/activate

# If on Windows
venv\Scripts\activate

pip install -r requirements.txt
pip install pyinstaller

pyinstaller -F jinja_compiler.py

# Executable will be located in the newly created dist directory

Attribution

The SSE code for auto-reloading with the debug webserver is from the article Server-sent events in Flask without extra dependencies. The license for this code (MIT) can be found in SSE_LICENSE.

About

A command line application for compiling Jinja templates into static HTML files

Topics

Resources

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
SSE_LICENSE

Stars

Watchers

Forks

Releases

No releases published

Languages