Closed yekalkan closed 3 years ago
I also met this situation, in TemplateRenderer.RenderAsync , all model attributes must be lowercase, For example:
await _templateRenderer.RenderAsync(AbpIoEmailTemplates.ArticleNotifyNew, new { articletitle = article.Title });
also must be the same in a .tpl: {{ model.articletitle }}
Scriban default property and methods naming kebab-case. Using ArticleTitle atricle_title
. It's not bug.
NOTICE By default, Properties and methods of .NET objects are automatically exposed with lowercase and
_
names. It means that a property likeMyMethodIsNice
will be exposed asmy_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 aMemberRenamer
delegate
This is not a bug, but the documentation should be updated to as it states that camelCase is the default
https://github.com/abpframework/abp/blob/dev/docs/en/Text-Templating.md#pascalcase-vs-camelcase
PascalCase vs camelCase PascalCase property names (like UserName) is used as camelCase (like userName) in the templates.
and instead, it is using the snake case as the default member renamer as specified in scriban documentation
https://github.com/lunet-io/scriban/blob/master/doc/runtime.md#member-renamer
await _templateRenderer.RenderAsync(AbpIoEmailTemplates.ArticleNotifyNew, new { Title = article.Title })
Rendered as expected in template file with
{{ model.title }}
.await _templateRenderer.RenderAsync(AbpIoEmailTemplates.ArticleNotifyNew, new { ArticleTitle = article.Title })
isn't rendered in template file with any "case" combination. What i've tried:
{{ model.ArticleTitle }}
,{{ model.articleTitle }}
,{{ model.articletitle }}
.You can reproduce this on Hello Demo.