Refactor wrapper function used in rendering

Now it takes only the node as parameter and should return the new
template. It doesn't take the complete rendered text anymore.

The goal is to avoid stupid replaces when the node is a string (previous
version could not process strings with {}) and let wrapper writers be
more relaxed in their manipulations.

Also, node_ids are now always present in the nodes themselves. The node
dictionary is still only in the CodeDisplay, though, and cleared every
rendering, because we want the unused nodes to be garbage collected.

There should be no change to the user interface.