1.0.4 • Published 7 months ago

trulla-templates v1.0.4

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
7 months ago

Trulla Templates is like Handlebars or Mustache templates, but statically typed and safe!

C# Source Generator: NuGet Badge

F# Type Provider: NuGet Badge

Node cli: npm version

The Trulla Approcah

  • Provide a text template with:
    • template parameters
    • iterations
    • conditionals
  • A model type is infered from a given template.
  • An instance of the model is provided by the user for rendering the final template.

Examples and Usage

Node via CLI

Go to the Node CLI Documentation

C# usage via Source Generators

Go to the C# Documentation

F# usage via Type Providers**

Go to the F# Documentation

General Template Syntax

Have a look at the tests for more samples!

for loops (with separator)

{{for c in chars}}{{c}}{{end}}
  • With a given separator between items, this will render 'a;b;c' for given chars = "a"; "b"; "c":
{{for x in numbers|;}}{{x.id}}{{end}}

if/else

  • This will print "Order is active." or "Order is closed." depending on the value of order.isActive:
  • The else part is optional.
Order is {{if order.isActive}}active{{else}}closed{{end}}.

How it works internally

Trulla is implemented in F#. It basically contains everything a "real" language has, like

  • a parser
  • an untyped AST
  • type inference with a solver
  • a typed AST
  • code generation

If you want to know more, have a look at the (Internals)./src/docs/Internals.md.

1.0.4

7 months ago

1.0.3

7 months ago

1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago