Open TechWatching opened 6 years ago
Hello! Do you have a solution for this issue?
I am doing json templating with mustache-sharp and I need to create a custom tag (#comma} to inject a comma after each elements of the json collection except the last one to respect json formatting.
Unfortunately, I don't really see how to do that using mustach-sharp. I guess I have to inherit from InlineTagDefinition but after I don't see how to do it :
I have been thinking to use my new template like that :
{{ #each Items}} {{ Name }} {{ #comma #index Items }} {{/each}}
It would allow me to have access to current index and length of my collection in order to know if a comma is needed or not but I am not sure if it is the correct way to think or even if it can work.
I was using mustache sharp for adaptive cards but now that they handle templating in their sdk I have stop using mustache and don't know how to solve this issue sorry.
I am doing json templating with mustache-sharp and I need to create a custom tag (#comma} to inject a comma after each elements of the json collection except the last one to respect json formatting.
Unfortunately, I don't really see how to do that using mustach-sharp. I guess I have to inherit from InlineTagDefinition but after I don't see how to do it :
I have been thinking to use my new template like that :
{{ #each Items}} {{ Name }} {{ #comma #index Items }} {{/each}}
It would allow me to have access to current index and length of my collection in order to know if a comma is needed or not but I am not sure if it is the correct way to think or even if it can work.