Format the given Var as a javascript value. Args: var: The Var to format. Returns: The formatted Var.
(var: Var)
| 197 | |
| 198 | |
| 199 | def format_var(var: Var) -> str: |
| 200 | """Format the given Var as a javascript value. |
| 201 | |
| 202 | Args: |
| 203 | var: The Var to format. |
| 204 | |
| 205 | Returns: |
| 206 | The formatted Var. |
| 207 | """ |
| 208 | if not var._var_is_local or var._var_is_string: |
| 209 | return str(var) |
| 210 | if types._issubclass(var._var_type, str): |
| 211 | return format_string(var._var_full_name) |
| 212 | if is_wrapped(var._var_full_name, "{"): |
| 213 | return var._var_full_name |
| 214 | return json_dumps(var._var_full_name) |
| 215 | |
| 216 | |
| 217 | def format_route(route: str, format_case=True) -> str: |
no test coverage detected