A simple string templating library for Nim.



A simple string templating library for Nim


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

import templates

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

echo testPage("Charlie")


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
Need help? Read Nimble
No tagged versions available
License: BSD

Project website Hosted docs