Render the string with the given context, but avoid replacing text inside angle brackets if context is missing. Args: input_string (str): The string for which to render/replace params. render_context (Mapping[str, object]): The context for rendering the string. Ret
(input_string: str, render_context: Mapping[str, object])
| 25 | |
| 26 | |
| 27 | def render_string(input_string: str, render_context: Mapping[str, object]) -> str: |
| 28 | """ |
| 29 | Render the string with the given context, |
| 30 | but avoid replacing text inside angle brackets if context is missing. |
| 31 | |
| 32 | Args: |
| 33 | input_string (str): The string for which to render/replace params. |
| 34 | render_context (Mapping[str, object]): The context for rendering the string. |
| 35 | |
| 36 | Returns: |
| 37 | str: The rendered string with parameters replaced only if they exist in the context. |
| 38 | """ |
| 39 | |
| 40 | def replacer(m: re.Match) -> str: |
| 41 | varname = m.group(1) |
| 42 | # If the context contains the variable, replace it. Otherwise, leave it unchanged. |
| 43 | return str(render_context.get(varname, f"<{varname}>")) |
| 44 | |
| 45 | return PARAM_RE.sub(replacer, input_string) |
| 46 | |
| 47 | |
| 48 | def get_tag_names(tag_data: list[GherkinTag]) -> set[str]: |
no outgoing calls
no test coverage detected
searching dependent graphs…