11 releases
0.2.4 | Jun 20, 2024 |
---|---|
0.2.3 | May 8, 2024 |
0.2.1 | Apr 23, 2024 |
0.1.7 | Apr 18, 2024 |
#2330 in Command line utilities
1,182 downloads per month
31KB
627 lines
Jango
A CLI application to populate your templates.
Features
- Create templates with Jinja-inspired Tera syntax.
- Custom
content
field that can be populated with the command line. - Arbitrary template fields with Markdown TOML frontmatters.
- Written in Rust, btw.
Installation
Prebuilt Binaries
Install prebuilt binaries via shell script
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/DavoReds/jango/releases/download/v0.2.4/jango-installer.sh | sh
This works for both Linux & MacOS.
Install prebuilt binaries via powershell script
powershell -c "irm https://github.com/DavoReds/jango/releases/download/v0.2.4/jango-installer.ps1 | iex"
You can also download the prebuild binaries manually from the releases page.
Crates.io
If you have Rust installed, you can build Jango from source using the crates.io registry.
cargo install jango
Or download a prebuilt binary with cargo-binstall.
cargo binstall jango
Usage
With CLI arguments
This mode allows for a template containing any of Tera's builtins and a variable called content
that corresponds to the command line argument of the same name.
The template could look something like this:
---
date: {{ now() | date(format="%F") }}
---
# This is a title
{{ content }}
And you would populate it with this command:
jango args template.md output.md -c "Hello, **world\!**"
Which would result in this file:
---
date: 2024-04-05
---
# This is a title
Hello, **world!**
If you are manipulating HTML, you can use the --escape
flag if you wish to escape the input given to the command.
With a Markdown file
When dealing with more complex templates, you can use a Markdown file with a TOML frontmatter to pass any arbitrary variables beyond the file's content
.
The template can look something like this:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>{{ title }}</title>
</head>
<body>
{{ content | indent }}
</body>
</html>
You can write a Markdown file like this:
+++
title = "This is a title"
+++
# This is a heading
This is a paragraph.
Then execute a command like this:
jango markdown template.html markdown.md output.html
Which would result in this file:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>This is a title</title>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
Contributing
Contributions are always welcome!
You're going to need to have Rust installed. I also recommend having Bacon (to handle recompilation) and cargo-nextest (for a nicer interface when running tests) installed.
We also try to conventional commit conventions when contributing to the repo.
(Un)License
Dependencies
~18–28MB
~407K SLoC