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 (8)

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.

Morestachio.Runner

Package Description

Morestachio.System.Xml.Linq

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
5.0.1.631 12,598 8/1/2022
5.0.1.622 2,578 6/23/2022
5.0.1.615 2,395 6/15/2022
5.0.1.613 2,865 6/15/2022
5.0.1.589 1,739 5/12/2022
5.0.1.570 2,978 4/9/2022
5.0.1.534 5,701 10/20/2021
5.0.0.513 2,317 5/2/2021
5.0.0.504 1,464 3/3/2021
5.0.0.503 670 2/24/2021
5.0.0.487 674 2/18/2021
4.3.3.480 782 1/27/2021
4.3.3.478 668 1/14/2021
4.3.2.476 683 1/14/2021
4.3.2.472 903 1/12/2021
4.3.2.460 670 1/3/2021
4.3.2.459 644 12/29/2020
4.3.2.457 784 12/4/2020
4.3.2.450 739 11/3/2020
4.3.2.441 986 10/28/2020
4.3.1.413 752 9/26/2020
4.3.0.405 898 9/11/2020
4.3.0.397 750 9/4/2020
4.3.0.392 749 8/24/2020
4.2.0.376 853 8/8/2020
4.0.1.374 761 8/8/2020
4.0.1.367 826 7/28/2020
4.0.1.355 740 7/24/2020
4.0.1.342 665 7/16/2020
4.0.1.332 2,172 6/30/2020
4.0.1.323 493 6/30/2020
4.0.0-alpha2 341 6/18/2020
4.0.0-alpha1 462 6/13/2020
3.0.1 1,583 3/16/2020
3.0.0 538 3/9/2020
3.0.0-alpha7 415 1/9/2020
3.0.0-alpha6 450 1/9/2020
3.0.0-alpha5 446 1/9/2020
3.0.0-alpha4 396 11/10/2019
3.0.0-alpha3 371 11/9/2019
3.0.0-alpha2 369 11/6/2019
3.0.0-alpha1 358 11/2/2019
2.3.8 7,774 10/31/2019
2.3.7 542 10/24/2019
2.3.6 1,185 10/16/2019
2.3.5 555 9/6/2019
2.3.4 555 9/5/2019
2.3.3 597 8/24/2019
2.3.2 592 8/24/2019
2.3.1 592 8/23/2019
2.3.0 596 8/11/2019
2.2.135 708 12/24/2018
2.2.134 696 12/23/2018
2.2.133 690 12/23/2018
2.2.132 682 12/18/2018
2.2.131 677 12/18/2018
2.2.130 721 12/1/2018
2.2.129 730 12/1/2018
2.2.121 798 10/2/2018
2.2.120 802 9/29/2018
2.2.119 820 9/27/2018
2.2.118 796 9/27/2018
2.2.117 788 9/27/2018
2.2.116 767 9/27/2018
2.2.115 762 9/26/2018
2.2.114 765 9/26/2018
2.2.111 787 9/25/2018
2.2.110 880 9/25/2018
2.2.108 782 9/25/2018
2.2.107 789 9/25/2018
2.2.106 787 9/25/2018
2.2.105 800 9/25/2018
2.2.104 775 9/25/2018
2.2.91 931 9/23/2018
2.2.90 782 9/23/2018
2.2.82 800 9/12/2018
2.2.60 805 9/12/2018
2.2.56 833 9/12/2018