jehugaleahsa / mustache-sharp

An extension of the mustache text template engine for .NET.
The Unlicense
306 stars 80 forks source link

Help creating custom tag #91

Open skedlyio opened 5 years ago

skedlyio commented 5 years ago

First, let me say I'm loving this project. However, I'm finding it hard to get help creating a custom tag. The docs are a little light as are the tests. Generally speaking, I think many people would benefit from more docs and tests.

My specific need right now is creating a custom tag that would render a random element. So, my template would be:

`

{{#Random}} {{#Voice}} Phrase one {{/Voice}} {{#Voice}} Phrase two {{/Voice}} {{/Random}}

`

As you can see, I'm creating html, more specifically ssml for an Alexa skill.

I've found examples of FirstOf that takes the first element of a collection of strings. But I don't want my tag to be collection-type aware; it should render one of its child elements allowing me to use whatever nested-structure I choose.

Any help much appreciated

johnkamau commented 3 years ago

Did you ever figure this out?