Template rendering within layout bug fix