Use SaveAsFile for Mustache templates

Close #5292