noahmorrison / chevron

A Python implementation of mustache
MIT License
480 stars 52 forks source link

Custom behaviour on missing variable #120

Open hovi opened 1 year ago

hovi commented 1 year ago

I would like the renderer to fail with exception when he can't find a value rather than rendering nothing. Any hopes for implementing that?

dcmoore-gd commented 1 year ago

That's built into the mustache syntax via inverted section:

{{#repo}}
  <b>{{name}}</b>
{{/repo}}
{{^repo}}
  No repos :(
{{/repo}}
hovi commented 1 year ago

That is slightly different. I have my templates and I expect my values to be there and just fail when the values are not there rather then have processed template with empty values.

For example this is how it's handled in jmustache: https://github.com/samskivert/jmustache#default-values