Since you can embed JSON with YAML files, one solution is to generate the equivalent JSON representation of the data structure that YAML would produce. Since the JSON structure is insensitive to indentation, this appears to be a solution to using macros in a generalized way.
Since you can embed JSON with YAML files, one solution is to generate the equivalent JSON representation of the data structure that YAML would produce. Since the JSON structure is insensitive to indentation, this appears to be a solution to using macros in a generalized way.
See my post https://community.home-assistant.io/t/fun-with-lovelace-gen-and-jinja2-macros-to-avoid-whitespace-indentation-problems/236427 for an example.