def METHOD_NAME(self, template):
    """
    Replace each $-substitutions in the given template string with
    the corresponding terminal control string (if it's defined) or
    '' (if it's not).
    """
    return re.sub(br'\$\$|\${\w+}', self._render_sub, template)