templater
A new awesome nimble package
Summary
| Latest Version | 1.0.3 |
|---|---|
| License | MIT |
| CI Status | Failing |
| Downloads | 0 |
| Last Indexed | 2026-07-21 05:26 |
Tags
Authors
- Isaac Naylor
Installation
nimble install templater
choosenim install templater
git clone https://github.com/Wraith29/templater
OS Compatibility
| Platform | Linux | macOS | Windows | FreeBSD | OpenBSD | NetBSD | Android | iOS | WASM | Embedded |
|---|---|---|---|---|---|---|---|---|---|---|
| templater | ✓ | ✓ | ✓ | - | - | - | - | - | - | - |
Dependencies
| Package | Version | Optional |
|---|---|---|
| nim >= | 2.1.1 | No |
| regex | - | No |
Source
| Repository | https://github.com/Wraith29/templater |
|---|---|
| Homepage | https://github.com/Wraith29/templater |
| Registry Source | nimble_official |
README
Templater
A Nim-based HTML templating engine inspired by Python's Jinja.
Performs Compile-time template validation, to ensure you don't get any nasty surprises when running your code.
Installation
Global Installation:
nimble install templater
Local Installation:
atlas init
atlas use templater
Usage
Load from Template String
import templater
const myTemplate = """
<!DOCTYPE html>
<html>
<head>
<title>{{pageTitle}}</title>
</head>
<body>
<h1>{{myHeader}}</h1>
<ul>{{#for item in items | index}}
<li>{{#index}}: {{#item}}</li>
{{#endfor}}</ul>
</body>
</html>
"""
let vars = newVarTable(("pageTitle", newVariable("My Page Title")), ("myHeader", newVariable("Page Header")), ("items", newVariable(@[newVariable("Item 0"), newVariable("Item 1")])))
let renderedTemplate = loadTemplate(myTemplate, vars)
Load from a Template file
let vars = newVarTable(("pageTitle", newVariable("My Page Title")), ("myHeader", newVariable("Page Header")), ("items", newVariable(@[newVariable("Item 0"), newVariable("Item 1")])))
let renderedTemplate = loadTemplateFile(staticRead("template.html"), vars)
Template Syntax
Variables:
<!DOCTYPE html>
<html>
<head>
<title>{{pageTitle}}</title>
</head>
<body>
<h1>{{welcomeMessage}}</h1>
</body>
</html>
Lists:
<!DOCTYPE html>
<html>
<head>
<title>My Page</title>
</head>
<body>
<li>
{{#for item in items}}
<li>{{#item}}</li>
{{#endfor}}
</li>
<li>
{{#for item in items | index}} <!--index here is optional, and can be named anything-->
<li>{{#index}}: {{#item}}</li>
{{#endfor}}
</li>
</body>
</html>