Closed brikis98 closed 8 years ago
@josh-padnick This is ready for review
I haven't reviewed the code yet, but at first blush, invalid
seems like the wrong word to return a placeholder. "Invalid" makes me think that if something isn't valid, an error should be thrown. Otherwise, we're just marking something explicitly as empty. So I vote to use the word placeholder
instead.
Left minor comments but overall LGTM! Feel free to respond as desired and merge.
I haven't reviewed the code yet, but at first blush, invalid seems like the wrong word to return a placeholder. "Invalid" makes me think that if something isn't valid, an error should be thrown. Otherwise, we're just marking something explicitly as empty. So I vote to use the word placeholder instead.
It's based on the names of the settings supported by Go's templating system:
"missingkey=default" or "missingkey=invalid"
The default behavior: Do nothing and continue execution.
If printed, the result of the index operation is the string
"<no value>".
"missingkey=zero"
The operation returns the zero value for the map type's element.
"missingkey=error"
Execution stops immediately with an error.
Merging now!
This PR adds a new flag to boilerplate called
missing-key-action
. This flag determines what boilerplate will do if a template references a variable that is not defined:error
(default): exit with an error. Making this the default helps to catch a lot of bugs and typos in your templates.invalid
: render the text<no value>
.zero
: render the zero value of the variable. For now, this will always be an empty string, but if we support types for variables, it will be different for each type.