All Projects → smolyakoff → essential-templating

smolyakoff / essential-templating

Licence: MIT License
A set of templating libraries.

Programming Languages

C#
18002 projects
powershell
5483 projects
HTML
75241 projects

Projects that are alternatives of or similar to essential-templating

Giraffe.Razor
Razor view engine http handlers for Giraffe web applications.
Stars: ✭ 27 (+28.57%)
Mutual labels:  template-engine, razorengine
hulk-template
为 CodeIgniter 框架增加视图继承功能,不改变原有视图编写方式,无缝增加视图继承功能。
Stars: ✭ 17 (-19.05%)
Mutual labels:  template-engine
django-mustache
Mustache (Pystache) template engine for Django 1.8 and newer, with support for Django context processors. Designed to support offline-capable web apps via progressive enhancement.
Stars: ✭ 20 (-4.76%)
Mutual labels:  template-engine
idris-tmustache
Total Logic-Less Templating Library
Stars: ✭ 12 (-42.86%)
Mutual labels:  template-engine
pyxl4
Extend Python syntax with HTML.
Stars: ✭ 68 (+223.81%)
Mutual labels:  template-engine
kotlin-html
A library to generate HTML in Kotlin.
Stars: ✭ 23 (+9.52%)
Mutual labels:  template-engine
karkas
A tiny template engine based on TypeScript
Stars: ✭ 14 (-33.33%)
Mutual labels:  template-engine
thera
A template engine for Scala
Stars: ✭ 49 (+133.33%)
Mutual labels:  template-engine
yatpl
Yet Another Template Engine 🚀
Stars: ✭ 14 (-33.33%)
Mutual labels:  template-engine
lua-resty-aries
openresty and lua multi-function template
Stars: ✭ 47 (+123.81%)
Mutual labels:  template-engine
typesafe-templates
Template engine that leverages JSX to generate JavaScript code from TypeScript code files rather than text templates.
Stars: ✭ 27 (+28.57%)
Mutual labels:  template-engine
korte
Kotlin cORoutines Template Engine for Multiplatform Kotlin
Stars: ✭ 69 (+228.57%)
Mutual labels:  template-engine
moustachu
Mustache templating for Nim
Stars: ✭ 58 (+176.19%)
Mutual labels:  template-engine
Hierarchy
No-dependencies package that embodies WordPress template hierarchy
Stars: ✭ 78 (+271.43%)
Mutual labels:  template-engine
tonic
Super fast and powerful PHP template engine
Stars: ✭ 48 (+128.57%)
Mutual labels:  template-engine
engine
A pragmatic approach to templating for PHP 7.x+
Stars: ✭ 31 (+47.62%)
Mutual labels:  template-engine
shaven
DOM building utility & Template engine based on JsonML + syntax sugar
Stars: ✭ 66 (+214.29%)
Mutual labels:  template-engine
MulleScion
🌱 A modern template engine for Objective C
Stars: ✭ 14 (-33.33%)
Mutual labels:  template-engine
Contemplate
Contemplate: Fast, extendable object-oriented and light-weight Template Engine for PHP, Python, Node.js, Browser and XPCOM/SDK JavaScript
Stars: ✭ 15 (-28.57%)
Mutual labels:  template-engine
katapult
Kickstart Rails development!
Stars: ✭ 21 (+0%)
Mutual labels:  template-engine

Essential Templating Analytics

Essential Templating is a set of libraries to render templated objects (like web pages, documents or emails).

  • Allows to render complex objects from a single-file template.
  • Provides easy to use template engine interface with C# 5.0 async methods.
  • Unified template location (you can use files or .resx resources).
  • Localization support.

⚠️ Deprecation Notice

This package is not actively maintained anymore due to lack of time and the amount of existing libraries that do similar things. There are many alternatives you can consider:

Render text using Razor templates

The Essential.Templating.Razor package allows you to render text using Razor templates. The implementation is based on RazorEngine which makes it easy to render templates without using ASP.NET MVC.

Assuming the template is located in Hello.cshtml file under Templates directory. Make sure the template is copied to the output directory.

@inherits Essential.Templating.Razor.Template
Hello, @ViewBag.Name!

To render a template to a System.String create an instance of ITemplateEngine and call the Render method.

ITemplateEngine engine = new RazorTemplateEngineBuilder()
                .FindTemplatesInDirectory("Templates")
                .CacheExpiresIn(TimeSpan.FromSeconds(20))
                .UseSharedCache()
                .Build();
string template = engine.Render(path: "Hello.cshtml", viewBag: new {Name = "John"});

The rendered result should look as follows:

Hello, John!

Render emails using Razor templates

The Essential.Templating.Razor.Email package allows to render System.Net.MailMessage instances from Razor templates. Both HTML and text bodies are supported and can be specified using Razor section syntax.

Assuming that you have a following template in Email.cshtml file under Templates directory.

@inherits Essential.Templating.Razor.Email.EmailTemplate
@using System.Net;
@{
    From = new MailAddress("[email protected]");
    Subject = "Email Subject";
}
@section Html
{
   <html>
      <head>
          <title>Example</title>
      </head>
      <body>
          <h1>HTML part of the email</h1>
      </body>
   </html>
}
@section Text 
{
    Text part of the email.
}

To get a System.Net.MailMessage object from this template use the following code:

ITemplateEngine engine = new RazorTemplateEngineBuilder()
                            .FindTemplatesInDirectory("Templates")
                            .Build();
MailMessage email = engine.RenderEmail("Email.cshtml");
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].