(
        value: Any, default: Optional[str] = None, sort_keys: bool = False
    )
The `tojson` context method can be used to serialize a Python
        object primitive, eg. a `dict` or `list` to a yaml string.

        :param value: The value serialize to yaml
        :param default: A default value to return if the `value` argument
            cannot be serialized
        :param sort_keys: If True, sort the keys.


        Usage:

            {% set my_dict = {"abc": 123} %}
            {% set my_yaml_string = toyaml(my_dict) %}
            {% do log(my_yaml_string) %}
The `tojson` context method can be used to serialize a Python
        object primitive, eg. a `dict` or `list` to a yaml string.
The tojson context method can be used to serialize a Python object primitive eg . a dict or list to a yaml string .
def toyaml(
        value: Any, default: Optional[str] = None, sort_keys: bool = False
    ) -> Optional[str]:
        """The `tojson` context method can be used to serialize a Python
        object primitive, eg. a `dict` or `list` to a yaml string.

        :param value: The value serialize to yaml
        :param default: A default value to return if the `value` argument
            cannot be serialized
        :param sort_keys: If True, sort the keys.


        Usage:

            {% set my_dict = {"abc": 123} %}
            {% set my_yaml_string = toyaml(my_dict) %}
            {% do log(my_yaml_string) %}
        """
        try:
            return yaml.safe_dump(data=value, sort_keys=sort_keys)
        except (ValueError, yaml.YAMLError):
            return default
def toyaml ( value : Any , default : Optional [ str ] = None , sort_keys : bool = False ) -> Optional [ str ] : try : return yaml . safe_dump ( data = value , sort_keys = sort_keys ) except ( ValueError , yaml . YAMLError ) : return default