Skip to content
A simple Cake addin for Handlebars templates.
Branch: develop
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
api
build
docfx
src
tools
.gitignore
LICENSE
README.md
ReleaseNotes.md
build.cake
build.ps1
build.sh

README.md

Cake.Handlebars

A simple Cake addin for rendering and compiling Handlebars templates

Installation

In your build script, add the following directive to install Cake.Handlebars:

#addin nuget:?package=Cake.Handlebars

Usage

This addin exposes four aliases for rendering and compiling, from either string or input file.

var result = RenderTemplate("Hello {{ name }}!", new { name = "World"});
result = RenderTemplateFromFile("./template.hbs", new { name = "World"});
var compiled = CompileTemplate("Hello {{ name}}!");
var result = compiled(new { name = "World"});

var template = CompileTemplateFromFile("./template.hbs");
result = template(new { name = "World"});

Writing to file

While the above examples will work anywhere you want the string output, you can also write directly to a file using the fluent WriteToFile method:

RenderTemplate("Hello {{ name }}!", new { name = "World"}).WriteToFile("./output.txt");
var compiled = CompileTemplate("Hello {{ name}}!");
var result = compiled(new { name = "World"}).WriteToFile("./output.txt");
You can’t perform that action at this time.