No description
Find a file
2019-10-20 09:42:51 -05:00
templates Fixed 1.0 compiler deprecation warnings, generated exclude test bin files from git 2019-10-20 09:42:51 -05:00
tests Fix issue with single character disappearing 2018-10-13 00:45:20 -04:00
.gitignore Fixed 1.0 compiler deprecation warnings, generated exclude test bin files from git 2019-10-20 09:42:51 -05:00
LICENSE Initial commit 2014-05-25 16:07:53 -07:00
README.md Fixed example 2017-09-28 08:26:15 -05:00
templates.nim Fixed 1.0 compiler deprecation warnings, generated exclude test bin files from git 2019-10-20 09:42:51 -05:00
templates.nimble Fixed 1.0 compiler deprecation warnings, generated exclude test bin files from git 2019-10-20 09:42:51 -05:00

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