jehugaleahsa / mustache-sharp

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

Feature Request: {{#unless ...}} #9

Closed PaulGrimshaw closed 11 years ago

PaulGrimshaw commented 11 years ago

Would it be possible to implement handler for {{#unless ...}}, which is an inverse of {{#if ...}}?

In certain situations this can save many nested ifs.

Also, I note that the handler bar docs use {{else}} without a hash tag, where as your version uses the hash. Don't have a huge issue with this, just wanted to check it was "By Design"

jehugaleahsa commented 11 years ago

All tags have hashes. I'll think about the inverse tags. Although the code would be an almost exact copy of the IfTagDefinition. On Aug 1, 2013 6:25 AM, "Paul Grimshaw" notifications@github.com wrote:

Would it be possible to implement handler for {{#unless ...}}, which is an inverse of {{#if ...}}?

In certain situations this can save many nested ifs.

Also, I note that the handler bar docs use {{else}} without a hash tag, where as your version uses the hash. Don't have a huge issue with this, just wanted to check it was "By Design"

— Reply to this email directly or view it on GitHubhttps://github.com/jehugaleahsa/mustache-sharp/issues/9 .

PaulGrimshaw commented 11 years ago

True, just realised the following:

{{#if Paid}}{{#else}}Pay Now{{/if}}

is identical to

{{#unless Paid}}Pay Now{{/unless}}

jehugaleahsa commented 11 years ago

That is a pretty cool technique. I probably would have never thought of that.

On Thu, Aug 1, 2013 at 8:47 AM, Paul Grimshaw notifications@github.comwrote:

True, just realised the following:

{{#if Paid}}{{#else}}Pay Now{{/if}}

is identical to

{{#unless Paid}}Pay Now{{/unless}}

— Reply to this email directly or view it on GitHubhttps://github.com/jehugaleahsa/mustache-sharp/issues/9#issuecomment-21933790 .