Sitecore Asked on November 7, 2021
Is it possible to use the current Model in Scriban?
I have a CutomHeroViewModel
public class CustomHeroViewModel : VariantsRenderingModel
{
public string HeroTitle { get; set; }
public string HeroDescription { get; set; }
public List<string> ImageUrl { get; set; }
}
I would like to use its properties in a Scriban template.
I tried the following code {{ o_model.HeroTitle }} but its showing empty value
Any help or suggestion would be appreciated.
Thanks in advance
Yes, it is possible. Keep in mind that Scriban by default is lower casing properties and using underscore to separate the words. So property called VariantFields
will be accessible in Scriban by variant_fields
. Take a look here:
Please refer to the Scriban documentation for more details: https://github.com/lunet-io/scriban
By default, Properties and methods of .NET objects are automatically exposed with lowercase and _ names. It means that a property like MyMethodIsNice will be exposed as my_method_is_nice. This is the default convention, originally to match the behavior of liquid templates. If you want to change this behavior, you need to use a MemberRenamer delegate.
Answered by Dawid Rutkowski on November 7, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP