rfc101 refactoring, add support for html legend templates