Improve template variables replacement in config items
Right now the replacement is implemented in more than one place and is very simple, this should be unified and improved. This issue is not to track the long term goal to create a proper template meta language, just to improve the current simple imlementation.