Move the node attribute handling into a library.
Make the template take the configuration object