fix bug in template rendering that crashed server