zPdfGenerator.TemplatePreview
0.1.8
dotnet tool install --global zPdfGenerator.TemplatePreview --version 0.1.8
dotnet new tool-manifest
dotnet tool install --local zPdfGenerator.TemplatePreview --version 0.1.8
#tool dotnet:?package=zPdfGenerator.TemplatePreview&version=0.1.8
nuke :add-package zPdfGenerator.TemplatePreview --version 0.1.8
zPdfGenerator.TemplatePreview
zPdfGenerator.TemplatePreview is a .NET global tool that provides a fast and generic way to preview HTML templates rendered with Fluid (Liquid syntax) using sample JSON data.
It is designed to help you author, debug, and iterate on HTML templates that will later be converted to PDF (for example using zPdfGenerator), without having to write code or regenerate PDFs constantly.
Features
- Preview any HTML template using Fluid/Liquid syntax
- Uses a side-by-side
*.sample.jsonfile as mock data - Opens the rendered HTML automatically in your browser
--watchmode to re-render instantly on file changes- Distributed as a .NET global tool
- No knowledge of placeholders required — fully generic
Installation
The tool is distributed as a NuGet .NET Tool.
Prerequisites
- .NET 8 SDK or Runtime installed
Install globally
dotnet tool install -g zPdfGenerator.TemplatePreview
Verify installation:
zg-templates --help
Usage
Basic usage
zg-templates preview Templates/Invoice.html
Using a full path (with spaces)
zg-templates preview "Templates/My Invoice.html"
Watch mode (recommended)
zg-templates preview Templates/Invoice.html --watch
- Re-renders automatically when the HTML or JSON changes
- Refresh the browser (F5) to see updates
Options
| Option | Description |
|---|---|
--watch |
Re-render when template or JSON changes |
--pdf |
Output a PDF instead of opening a browser |
--no-open |
Do not open browser automatically |
--help |
Show help |
Example:
zg-templates preview Templates/Invoice.html --watch
Template conventions
HTML template
Use Fluid / Liquid syntax:
<h1>Invoice {{ InvoiceNumber }}</h1>
{% if ShowDiscounts %}
<div>Discounts section</div>
{% endif %}
<ul>
{% for line in Lines %}
<li>{{ line.Description }} - {{ line.Price }}</li>
{% endfor %}
</ul>
Sample JSON
{
"InvoiceNumber": "INV-001",
"ShowDiscounts": true,
"Lines": [
{ "Description": "Consulting", "Price": 500 },
{ "Description": "License", "Price": 200 }
]
}
Design goals
- No strong typing
- No predefined placeholders
- No coupling to PDF generation
- Works with any HTML template
- Optimized for template authoring and previewing
Related projects
This tool is part of the zGenerators ecosystem:
zExcelGenerator
Excel reports with a fluent API
https://github.com/juanjozorry/zGeneratorszPdfGenerator
PDF generation from Forms and HTML templates
https://github.com/juanjozorry/zGenerators
License
MIT License © Juanjo Jiménez Zorrilla
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
This package has no dependencies.