I’m using .Site.Data.file.value to read some key data into my homepage template. This works fine but I want this usage to fail with an error on build if the value doesn’t exist. I’ve looked through the build flags and available template functions but I can’t find anything that “asserts” or “requires” a value to be a non-empty or non-nil value.
Does this exist already, or should I try to create a partial template which spits out an error?
That’s a clever way to use the with operator, but I’d like something even shorter since I tend to want to know when a value is missing before I deploy rather than maybe (or not) discovering it later.
I see that Go templates have an optionmissingkey=error which would solve this globally if it was set. It would be nice if this option could be set from the command line.
I could maybe create a preprocessor or something similar that would inject your code whenever an assert function was found?