Extract template content in the wrapper

This fixes the todo and should lead to less confusing behavior.