jehugaleahsa / mustache-sharp

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

Is there a way to suppress KeyNotFoundException? #58

Closed oscaruribe closed 8 years ago

oscaruribe commented 8 years ago

If you're trying to render a text and the data doesn't include a key it fails, I'd rather it just replaced with blank. Is there any way to do that with a flag?

jehugaleahsa commented 8 years ago

You can add an event handler to the generator and set the Handled property to true. https://github.com/jehugaleahsa/mustache-sharp/blob/master/mustache-sharp/KeyNotFoundEventArgs.cs On Feb 11, 2016 4:51 PM, "oscaruribe" notifications@github.com wrote:

If you're trying to render a text and the data doesn't include a key it fails, I'd rather it just replaced with blank. Is there any way to do that with a flag?

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

oscaruribe commented 8 years ago

Awesome! Worked like a charm. Thanks Travis!

Best regards

Oscar Uribe Founder / Chief Executive Officer oscar.uribe@ungapped.commailto:oscar.uribe@ungapped.com | SE: +46 733 526 000, US: +1 (415) 505 68 63 www.linkedin.com/in/oscaruribehttp://www.linkedin.com/in/oscaruribe

[Ungapped]http://www.ungapped.com/ Ungapped | ungapped.comhttps://ungapped.com/ Rådmansgatan 65, 113 60 Stockholm Sweden | +46 (0)8 410 413 13 180 Sansome St, San Francisco, CA 94104 | +1 (800) 931-6339

Follow: Facebookhttps://www.facebook.com/ungapped | Twitterhttps://twitter.com/ungapped | LinkedInhttps://www.linkedin.com/company/ungapped | Pinteresthttps://www.pinterest.com/ungapped/

Från: Travis Parks [mailto:notifications@github.com] Skickat: den 11 februari 2016 14:03 Till: jehugaleahsa/mustache-sharp mustache-sharp@noreply.github.com Kopia: Oscar Uribe Enggren oscar.uribe@ungapped.com Ämne: Re: [mustache-sharp] Is there a way to suppress KeyNotFoundException? (#58)

You can add an event handler to the generator and set the Handled property to true. https://github.com/jehugaleahsa/mustache-sharp/blob/master/mustache-sharp/KeyNotFoundEventArgs.cs On Feb 11, 2016 4:51 PM, "oscaruribe" notifications@github.com<mailto:notifications@github.com> wrote:

If you're trying to render a text and the data doesn't include a key it fails, I'd rather it just replaced with blank. Is there any way to do that with a flag?

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

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