Optimizing template engines