This gist repository contains C# code examples from the Working with HTML Template chapter of the Aspose.HTML for .NET documentation. These gists demonstrate how to populate HTML templates with data, convert templates to standard HTML, and programmatically control template attributes when generating dynamic content.
HTML templates are a powerful way to create structured, reusable layouts that can be populated from data sources, for example, XML or JSON. Using Aspose.HTML for .NET, you can programmatically manipulate templates, insert content, and convert results into a variety of formats.
- Populate HTML templates with data from various sources.
- Set attributes in HTML template and control the presence of attributes when populating with data.
- Render and save the populated HTML template to formats like HTML, PDF, or images.
| Example Folder | Description |
|---|---|
Example-ConvertWithASingleLine |
Converts an HTML template to HTML using a single line of code, taking a template file and a JSON data source. |
Example-ConvertTemplate |
Converts an HTML document from a source path using a specified XML template data file and saves the result to an output path. |
Example-ConvertHTMLTemplateOnTheFly |
Demonstrates how to prepare a JSON data source and an HTML template string, save them to files, and then populate the template with the data. |
Example-FillHTMLTemplate |
Shows how to create an HTML template with an input checkbox, set template data in XML format, convert the template to HTML, and then verify the checkbox's attributes and state. |
Example-UncheckedTemplate |
Creates an HTML template with a disabled checkbox, uses an empty data source to ensure it's unchecked, and then verifies its state and attributes. |
- Install Aspose.HTML for .NET via NuGet.
- Configure paths, settings, and inputs to suit your environment.
- Browse the available gists and copy the code samples you need.
- Run your project to see the example in action.
You can download a free trial of Aspose.HTML for .NET and use a temporary license for unrestricted access.
For a comprehensive understanding, context, and detailed explanations of each example, please refer to the official documentation chapter Working with HTML Template.
- Documentation – Aspose.HTML for .NET
- Product page – Aspose.HTML for .NET
- Blog – Aspose.HTML Product Family
- API Reference – Aspose.HTML for .NET
- NuGet Package – Aspose.HTML for .NET
- .NET 6 or later
- Aspose.HTML for .NET