Note: This article is about features in a version of Weathermap that is not yet released. It is aimed at those who are testing the new version, prior to it's release. Feel free to help with that testing process, but 0.96 is not a finished or fully tested release yet.
Once you start making larger maps, or maps with a lot of 'pretty' formatting in them, then you'll find that you cut & paste a lot of the same formatting commands into many nodes or links. Weathermap 0.96 adds the first version of a new template feature that aims to reduce the hassle of managing large maps.
Templates are pretty simple to use, and pretty simple to understand. There are a few gotchas, because of the way they are currently implemented, but nothing too horrible. There is one new keyword, TEMPLATE, that you use in the node or link that you'd like to have copy another objects settings.
Let's start with an example, and talk through it.

NODE server
   ICON 48 48 images/server.png
   LABEL {node:this:name}
   LABELOFFSET S
   LABELFONT 12
   LABELBGCOLOR none
   LABELFONTCOLOR 255 255 255
   
NODE my_dns_server
   TEMPLATE server
   POSITION 100 100

Here, we have a "template node" that has no POSITION, so it will never be drawn on the map. It's only purpose is to hold the common configuration options that all nodes will pick up by using the TEMPLATE keyword. The second node does just this - it only needs to have a POSITION (so it is drawn), and the TEMPLATE keyword, which copies all the settings from the 'server' node.
Templates can be "nested" - so a template node can have a TEMPLATE keyword itself. You might have a generic 'server' node, but also a more specialised 'dns_server' node, which is formatted like a server, but with a different icon, for example.
It's important to note that the usual DEFAULT node and link still work. In fact, internally, the default TEMPLATE is the DEFAULT node or link. All the TEMPLATE keyword does is tweak this.
Also, because this process happens at the time the config is read, there are some rules about which order things appear in the config file:

  • Any item with a TEMPLATE keyword must appear after the definition of that item. The editor helps here by writing out any nodes without position, or links without nodes right after the DEFAULT items, at the top of the config file.
  • The TEMPLATE keyword must be the first keyword for the node or link. This is because the 'contents' of that item are replaced with those from the template. If it wasn't the first keyword, you would loose some configuration.

Also, the item you copy from doesn't have to be a positionless node or nodeless link - you can use any other link or node, as long it is already defined by the time you use it.
Obviously, this stuff is a lot more useful when you have a large map of many similar things, or an automatically generated map, based on some external configuration. I've just written a small tool that parses Cisco switch configs, looking for a certain set of VLANs and VRFS, and uses that to generate a map with appropriate labelling and targets - using templates has allowed me to remove a few hundred lines of text from the map config file.