Templating with scriban

less than 1 minute read

Simply create a template and pass data object as parameter.

    var template = Template.Parse(@"
##Ownership 
**Domain Event** | **Subscriptions** | **Domain** | **Sub Domain** | **Team**  | **Team Lead** | **CodeBase**
--|--|--|--|--|--|--
 |   | [](/) |  |   |   | 

<br>
<br>
");
    return template.Render(new
    {
        _domainEvent.Name,
        _serviceDefinition.Domain,
        DomainLink = $"{CbWiki.DomainPageRoot}/{_serviceDefinition.Domain} Domain".ToWikiLink(),
        _serviceDefinition.SubDomain,
        _serviceDefinition.Team,
        _serviceDefinition.Repository
    });
    

As templeate, it has extensive support for template language. I use if and for

var template = Template.Parse(@"
  ##<font color=""red"">Description (OBSOLETE)</font>##Description
  ~~~~

  
");

Whicespace control

By default, any whitespace (including new lines) bofore or after a code block are copied as-is to the output. To use loop, “non greedy mode” using the charcter ~


[]()

Categories:

Updated:

Comments