1

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.

mr100
  • 4,340
  • 2
  • 26
  • 38

1 Answers1

1

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
});
mr100
  • 4,340
  • 2
  • 26
  • 38
  • A few links for context: https://github.com/scriban/scriban/issues/96 and https://github.com/scriban/scriban/blob/master/doc/runtime.md#member-renamer – mortenma71 Apr 23 '22 at 11:02