Fix variable access in template