Issue with providing data model to template with scriban on .net core

1.3k Views Asked by At

I am trying to generate a document from scriban template but no data is present in the output:

var template = Template.Parse("{{model.Data}}");
var renederdContent = template.Render(new {
        model = new {
            Data = "some string"
        }
    });

Yet the output is empty. This used to work perfectly on .net framework whereas on .net core I've got a problem.

1

There are 1 best solutions below

1
On BEST ANSWER

It seems the behavior of Scriban is different here in .net core. It changes names by default to a different case. For instance "Data" is changes to "data" and "PriceChanged" changes to "price_changed". To left the names unchanged you need to call Render method like this:

var renederedContent = template.Render(new {
    model = new {
        Data = "some string"
    },
    m => m.Name
});