Barber is cli-tool for generating files based on mustache templates. In addition it can read and process OpenAPI 3 specifications and generate code based on templates.
Barber is installed as a dotnet global tool.
dotnet tool install -g barber
# Show help
barber --help
# Render
barber render -i template.mustache -- -Var1=A212
# OpenAPI create configuration
barber openapi init
# OpenAPI process
barber openapi
You can use this command for processing any mustache template. Either you pass the variables per arguments or by passing in a json file.
barber render -i template.mustache -o index.html -- -Var1="Foo"
barber render -i template.mustache -o index.html -j data.json"
{
"Var1": "Foo"
}
Template File
<html>
<body>
<h1>{{ Var1 }}</h1>
</body>
</html>
Result File
<html>
<body>
<h1>Foo</h1>
</body>
</html>
Create initial configuration file.
barber openapi init"
Read OpenAPI specification file and generate code based on templates
barber openapi init"