agc93 / Cake.Handlebars

A simple Cake addin for Handlebars templates.

Home Page:https://agc93.github.io/Cake.Handlebars/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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");

About

A simple Cake addin for Handlebars templates.

https://agc93.github.io/Cake.Handlebars/

License:MIT License


Languages

Language:C# 57.4%Language:PowerShell 29.5%Language:Shell 13.2%