templates

A simple string templating library for Nim.

Pure Nim score 15/100 · tests present · no docs generated

Summary

Latest Version Unknown
License BSD
CI Status Failing
Downloads 0
Last Indexed 2026-07-21 05:23

Installation

nimble install templates
choosenim install templates
git clone https://github.com/onionhammer/nim-templates.git

OS Compatibility

Platform Linux macOS Windows FreeBSD OpenBSD NetBSD Android iOS WASM Embedded
templates - - - - - - -

Source

Repository https://github.com/onionhammer/nim-templates.git
Homepage https://github.com/onionhammer/nim-templates
Registry Source nimble_official

README

nim-templates

A simple string templating library for Nim

Usage

Import the 'templates' library at the top of your nim module, and use the syntax:

import templates

proc testPage (name: string): string = tmpli html"""
    <body>
        <h1>Hello $name!</h1>
    </body>
    """

echo testPage("Charlie")

Syntax

The templates syntax supports $for and $while loops, $if/$elif/$else, multi-line statements, $case statements, procedure calls, etc. Look at the tests.nim file for more examples.

Supported Syntaxes

Realistically any well-structured syntax can be used as a template, but the NimLime SublimeText plugin supports syntax highlighting for the following template types;

  • HTML / XML
  • CSS
  • Javascript
  • GLSL
  • RST
  • Markdown

These can be invoked as follows:

tmpli xml""" ... """
tmpli css""" ... """
# etc