Morestachio 2.2.56

There is a newer version of this package available.
See the version list below for details.
dotnet add package Morestachio --version 2.2.56                
NuGet\Install-Package Morestachio -Version 2.2.56                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Morestachio" Version="2.2.56" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Morestachio --version 2.2.56                
#r "nuget: Morestachio, 2.2.56"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Morestachio as a Cake Addin
#addin nuget:?package=Morestachio&version=2.2.56

// Install Morestachio as a Cake Tool
#tool nuget:?package=Morestachio&version=2.2.56                

<img src="http://assets.wildbit.com/postmark/misc/Morestachio-logo@2x.png" alt="Morestachio Logo" title="Pistachio + Mustache => Morestachio" width="148" height="149">

Morestachio

A Lightweight, powerful, flavorful, templating engine for C# and other .net-based languages.

What's this for?

Morestachio allows you to create simple text-based templates that are fast and safe to render. It's the heart of Postmark Templates, and we're ecstatic to provide it as Open Source to the .net community.

How to use Morestachio:
// Parse the template:
var sourceTemplate = "Dear {{name}}, this is definitely a personalized note to you. Very truly yours, {{sender}}"
var template = Morestachio.Parser.Parse(sourceTemplate);

// Create the values for the template model:
dynamic model = new ExpandoObject();
model.name = "John";
model.sender = "Sally";

// Combine the model with the template to get content:
var content = template(model);
Installing Morestachio:

Morestachio can be installed via NuGet:

Install-Package Morestachio
Key differences between Morestachio and mustachio

Morestachio is build upon Mustachio and extends the mustachio syntax in a few ways.

  1. each value can be formatted by adding formatter the the morestachio
  2. Templates will be parsed as streams and will create a new stream. This is better when creating larger templates and best for web as you can also limit the length of the "to be" created template to a certain size
  3. Morestachio accepts any object besides the Dictionary<string,object> from mustachio.
Key differences between Morestachio and Mustache

Morestachio contains a few modifications to the core Mustache language that are important.

  1. each blocks are recommended for handling arrays of values. (We have a good reason!)
  2. Complex paths are supported, for example {{ this.is.a.valid.path }} and {{ ../this.goes.up.one.level }}
  3. Template partials ({{> secondary_template }}) are not supported. (We have a good reason!)
A little more about the differences:

One awesome feature of Morestachio is that with a minor alteration in the mustache syntax, we can infer what model will be required to completely fill out a template. By using the each keyword when interating over an array, our parser can infer whether an array or object (or scalar) should be expected when the template is used. Normal mustache syntax would prevent us from determining this.

We think the model inference feature is compelling, because it allows for error detection, and faster debugging iterations when developing templates, which justifies this minor change to 'vanilla' mustache syntax.

Template partials are a great feature for large scale template development. However, they introduce the risk of infinite recursion if used improperly (especially since Morestachio allows for one to navigate 'up' a model with ../).

In our use case (email templating), including partials would complicate the general process of creating the templates, and allow unknown users to create potentially unbound processing requirements on our servers. It is possible to detect these cycles while parsing templates, so, if this is important to our customers, or the broader OSS community, partial template support may be added to Morestachio in the future.

Infos about new features

Its now possible to add plain objects to the Dictionary. They will be called by reflection. Also you can now spezify the excact Size of the template to limit it (this could be come handy if you are in a hostet env). Also there is a new Operator {{?}}. Use it the access the current value direct. This will invoke ToString on the object in the current scope. Its good for cases where you are looping through a collection of primitives like:

{{#each Data.ArrayOfInts}} Current int: {{?}} {{/each}}

Formatter

Use the ContextObject.PrintableTypes collection to create own formatter for your types or add one to the new ParserOptions object for just one call. To invoke them in your template use the new Function syntax: {{Just.One.Formattable(AnyStringFormat).Thing}}

The formatter CAN return a new object on wich you can call new Propertys or it can return a string. There are formatter prepaired for all Primitve types. That means per default you can call on an object hat contains a DateTime:

{{MyObject.DateTime(D)}}

Product Compatible and additional computed target framework versions.
.NET Framework net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (9)

Showing the top 5 NuGet packages that depend on Morestachio:

Package Downloads
Morestachio.Newtonsoft.Json

Package Description

Morestachio.Linq

The Linq Formatters that require complex arguments for the Morestachio nuget package

Morestachio.LessCompiler

A powerfull c# infused templating engine.

Didot.Core

Package Description

Morestachio.Runner

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
5.0.1.631 20,748 8/1/2022
5.0.1.622 2,699 6/23/2022
5.0.1.615 2,519 6/15/2022
5.0.1.613 2,991 6/15/2022
5.0.1.589 1,819 5/12/2022
5.0.1.570 3,256 4/9/2022
5.0.1.534 5,808 10/20/2021
5.0.0.513 2,391 5/2/2021
5.0.0.504 1,527 3/3/2021
5.0.0.503 724 2/24/2021
5.0.0.487 737 2/18/2021
4.3.3.480 842 1/27/2021
4.3.3.478 721 1/14/2021
4.3.2.476 737 1/14/2021
4.3.2.472 978 1/12/2021
4.3.2.460 733 1/3/2021
4.3.2.459 696 12/29/2020
4.3.2.457 839 12/4/2020
4.3.2.450 792 11/3/2020
4.3.2.441 1,043 10/28/2020
4.3.1.413 810 9/26/2020
4.3.0.405 951 9/11/2020
4.3.0.397 804 9/4/2020
4.3.0.392 800 8/24/2020
4.2.0.376 914 8/8/2020
4.0.1.374 816 8/8/2020
4.0.1.367 875 7/28/2020
4.0.1.355 798 7/24/2020
4.0.1.342 716 7/16/2020
4.0.1.332 2,213 6/30/2020
4.0.1.323 534 6/30/2020
4.0.0-alpha2 368 6/18/2020
4.0.0-alpha1 494 6/13/2020
3.0.1 1,637 3/16/2020
3.0.0 568 3/9/2020
3.0.0-alpha7 444 1/9/2020
3.0.0-alpha6 479 1/9/2020
3.0.0-alpha5 474 1/9/2020
3.0.0-alpha4 423 11/10/2019
3.0.0-alpha3 401 11/9/2019
3.0.0-alpha2 393 11/6/2019
3.0.0-alpha1 383 11/2/2019
2.3.8 7,913 10/31/2019
2.3.7 584 10/24/2019
2.3.6 1,219 10/16/2019
2.3.5 587 9/6/2019
2.3.4 590 9/5/2019
2.3.3 635 8/24/2019
2.3.2 628 8/24/2019
2.3.1 632 8/23/2019
2.3.0 633 8/11/2019
2.2.135 746 12/24/2018
2.2.134 731 12/23/2018
2.2.133 725 12/23/2018
2.2.132 720 12/18/2018
2.2.131 711 12/18/2018
2.2.130 761 12/1/2018
2.2.129 766 12/1/2018
2.2.121 844 10/2/2018
2.2.120 849 9/29/2018
2.2.119 866 9/27/2018
2.2.118 842 9/27/2018
2.2.117 837 9/27/2018
2.2.116 798 9/27/2018
2.2.115 813 9/26/2018
2.2.114 811 9/26/2018
2.2.111 835 9/25/2018
2.2.110 941 9/25/2018
2.2.108 831 9/25/2018
2.2.107 835 9/25/2018
2.2.106 830 9/25/2018
2.2.105 845 9/25/2018
2.2.104 821 9/25/2018
2.2.91 1,005 9/23/2018
2.2.90 828 9/23/2018
2.2.82 845 9/12/2018
2.2.60 852 9/12/2018
2.2.56 1,074 9/12/2018