C#C
C#9mo ago
11 replies
VoidPointer

How to get indents for code formatting right in Scriban

I'm trying to use a Scriban template for generating a C# model class, and it's working OK so far, except for indentation. The template looks like this:
using Cassandra.Mapping.Attributes;
namespace {{model.name_space}};
public class {{model.name}}
{
{{ for prop in model.properties -}}
  {{ if model.is_partition_key }}[PartitionKey]{{ end }}
  {{- prop.access}} {{prop.type_name}} {{prop.name}} { get; set; }
{{ end }}
}

Then the rendered text looks like this:
using Cassandra.Mapping.Attributes;
namespace kyc_registration_msisdn_lookup;
public class kyc_registration_msisdn_lookup
{
public int hanis_image_status { get; set; }
public string identifier { get; set; }
public string identity_number { get; set; }
public Guid kyc_id { get; set; }
public DateTime modified_datetime { get; set; }
public string organization_code { get; set; }

}

What am I missing or doing wrong?
Was this page helpful?