Software in Review

Template Engine Component for NET

Developer ComponentPro
Category Software Development
Date Added October 24, 2015
Downloads n/a | 20
License Commercial

Editor's rating + + + + +

If you have found a broken link, please contact us

Get Full Version Home Page

Template Engine Component for NET
Reviewed by: Diana on 2018-06-29

Template Engine Component for .NET C#, VB.NET & ASP.NET

Easily generate formatted text output from source template, input variables, and .NET classes with a few lines of code. TemplateEngine is now available for .NET, Silverlight, Xamarin Android, iOS, and .NET Compact Framework.

Ultimate Template Engine's Key Features
• Can be used to generate any kind of text: HTML, XML, RTF, Email, Source Code, etc.
• Lightweight and easy to ship with your product (just only one DLL file).
• Template and TemplateClass can be loaded from many sources: file, stream, plain-text.
• Template and TemplateClass reusability (you can define one template that will be used for many further purposes).
• Utilizes the power of .NET Framework.
• Template syntax is similar to C# and very easy to understand
• Powerful template language with all usual directives: include, selection statements(if-else), Iteration Statements(do, for, foreach, while, break, continue).
• Initialize and change variables in template code.
• Support complex expressions.
• Powerful built-in functions (string, type conversion, collection rendering).
• Highly extensible with custom function.
• Smart and high-performance data type conversion.
• Get template source directory, it's very useful for including external files such as Css or Javascript files in your web page.
• Get and invoke any static, non-static public properties and methods in .NET Framework
• Allow or restrict the calls to specific .NET methods and properties.
• Powerful array and dictionary rendering methods.
• Able to change tag, expression and template comment delimiters to avoid confliction with other formats.
• Direct output to your own TextWriter.
• Able to cache parsed template data to speed up output text generation.
• Supports Unicode.
• Unified .NET exception.
• Support for .NET Full Framework, Xamarin iOS, Mac, Android, Mono, .NET CF, and .NET Core, Standard (will be available soon)

What is Template Engine?

The web publication uses a web template system that allows web designers and developers to work with web templates to automatically generate custom web pages, such as search results. This allows you to reuse the static elements of a Web page, allowing you to define dynamic elements based on the parameters of the Web request. Web templates are also used to create static content, providing the basic structure and appearance that are characteristic of web content. It can be present in content management systems, web applications and HTML editors.

Creating a project using the Template Engine component

Let's create a simple WPF application using the Template Engine component

We’ll need to add the necessary links to our project. Therefore, click on "Links" and select "Add link"

We’ll need to select such links - ComponentPro.TemplateEngine.dll ComponentPro.Common.dll. Which, I remind, are in the Extensions.

Working with the code

For full-time work, we must have a file with marking

We can count using standard tools in TextBlock , namely Stream class

using (StreamReader sr = new StreamReader(AppDomain.CurrentDomain.BaseDirectory + "EmailTemplate.htm"))
txtTemplate.Text = sr.ReadToEnd();

We can generate the text using the LoadFromString method of the TemplateEngine class. And then just substitute the variables, it looks like this:

TemplateEngine dt = new TemplateEngine();
// Create a custom object.
User u = new User();
u.EmailAddress = "[email protected]";
u.FullName = "John Borders";
u.Password = "123abc";
// Assignment of variables.
dt.SetValue("CompanyName", "My Company Name");
dt.SetValue("User", u);
dt.SetValue("OrderId", "1625DGHJ");
txtOutput.Text = dt.Run();

As a result, if you do everything correctly, the program will work so:

And after clicking the "Generate" button:

Conclusions and recommendations

When working with the Template Engine component, I realized how useful it is, because it is very easy to create, for example, letters to users or very simply to output the template text in applications. Simplicity in its creation, it is amazing, the main thing is to remember the necessary markup for the correct creation of the template and the matter behind the small one. You use the variables to replace and the output comes ready-formatted text. I think you all saw yourself in the example that was a couple of slides higher.

If you have found a broken link, please contact us

Get Full Version Home Page

Write your comment
Your Name:
Please enter the word above
into the Control box.
Featured Product
Mobile Device Lockdown. With SureLock, you can allow only desired applications to run on the device and only admin can access the password protected settings to either modify lockdown configurations or exit the lockdown.

Categories Tree
Operating Systems
Recently Added Developers
Products Archive
«        December 2020        »

Copyright © 2008-2017 TheDownloadPlanet, Inc. All Rights Reserved Terms of Use »  Disclaimer »  Privacy Policy »  Our Partners Free software - Pages in the main Google index, Pages in the supplemental Google index and Supplemental Ratio(!less is better!). Click image for more detailed information.