File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -15,10 +15,12 @@ def value_to_enum_name(value: Any, enum_path: str | None = None) -> str:
1515 """Convert a value to its enum member name using the specified enum class.
1616
1717 This filter takes a raw value and converts it to the corresponding enum member name by dynamically importing the
18- enum class.
18+ enum class if provided. The enum class can be any valid enum as long as its full import path is given .
1919
20- For example, `{{ decision__value | value_to_enum_name("infrahub.core.constants.PermissionDecision") }}`
21- will return: `"ALLOW_ALL"` for value `6`.
20+ If the value is already an instance of `Enum` and no `enum_path` is provided, it simply returns the name of the
21+ enum member which is equivalent to using `{{ value.name }}` in a Jinja2 template.
22+
23+ Usage example: `{{ decision__value | value_to_enum_name("infrahub.core.constants.PermissionDecision") }}` will return `"ALLOW_ALL"` for value `6`.
2224 """
2325 if isinstance (value , Enum ) and not enum_path :
2426 return value .name
You can’t perform that action at this time.
0 commit comments