lizoc / textscript

Text templating powered by .NET
MIT License
5 stars 2 forks source link
dotnet liquid-templating-engine template-engine templating

TextScript!

Text templating with .NET comfort

NuGet Package PowerShell Gallery MIT License

This project is a fork over Scriban

What does this do?

TextScript is a text templating engine. Designed to be powerful yet easy to learn, TextScript aims to provide the same functionality of liquid and more. TextScript is written entirely in .NET, so there's absolutely no need for ruby, python or a boatload of NodeJS npms!

TextScript is initially forked from Scriban in late 2018, and the code base has diverged since. Some primary differences are:

You can read more about a list of differences here.

Show me the money

How about some good old templating done right inside PowerShell?

ipmo TextScript
@{ name = 'Partner' } | ConvertFrom-Template -Template 'Howdy {{ name }}!'
# Howdy Partner!

Same thing in C#:

// Parse a template
var template = Template.Parse("Hello {{name}}!");
var result = template.Render(new { Name = "World" }); // => "Hello World!" 

TextScript borrows from the very popular liquid, which you are encouraged to look at too. In most of the cases, there is no difference at all:

ipmo TextScript
@{
  food = @(
    { name = 'cabbage'; price = '$10'; fullDesc = "Fresh and green" }
    { name = 'banana';  price = '$5';  fullDesc = "Minion's favorite" }
    { name = 'beef';    price = '$50'; fullDesc = "Meatlovers delight"}
  )
} | ConvertFrom-Template @'
<ul id='cart'>
  {{ for item in food }}
    <li>
      <h2>{{ item.name }}</h2>
           Price: {{ item.price }}
           {{ item.full_desc | string.truncate 15 }}
    </li>
  {{ end }}
</ul>
'@

Highlights

Documentation

Go to the documentation page to get started.

Binaries

Prebuilt binaries are available in the release tab.

To integrate TextScript in your .NET project, reference our NuGet package in your packages.config or project file: NuGet

TextScript can run on the following platforms:

To install our PowerShell cmdlet:

Install-Package TextScript

Platform specific implementations for PowerShell:

Benchmarks

We aim for real-time rendering! Compete results are updated in our benchmarks document.

License

See the LICENSE file for licensing information.

Related projects

We take inspirations from the following repos. For third party licensing info, refer to the third party license file.