def replace_macros(pattern: T, macros: MacroMapping) -> T: if isinstance(pattern, str): return replace_macros_in_str(pattern, macros) if isinstance(pattern, list): return replace_macros_in_list(pattern, macros) if isinstance(pattern, dict): return replace_macros_in_dict(pattern, macros)
def render_title_html(self) -> HTML: title = self.display_title() return text_with_links_to_user_translated_html([ ( replace_macros_in_str( title, self._get_macro_mapping(title), ), self.title_url(), ), ],)
def _translate_legacy_macros( cmd: str, hostname: HostName, ipaddress: Optional[HostAddress], ) -> str: # Make "legacy" translation. The users should use the $...$ macros in future return replace_macros_in_str( cmd, { "<IP>": ipaddress or "", "<HOST>": hostname, }, )
def render_title_with_macros_string( context: VisualContext, single_infos: SingleInfos, title: str, default_title: str, **additional_macros: str, ): return replace_macros_in_str( _u(title), macro_mapping_from_context( context, single_infos, title, default_title, **additional_macros, ), )
def render_title_with_macros_string( title: str, macro_mapping: MacroMapping, ): return replace_macros_in_str(_u(title), macro_mapping)