Open gadenbuie opened 1 month ago
In Python, I implemented this in e59ea9d9fdee0dea4d8efdc5e15e6a06789d0416. I was able to use pydantic's serialization context feature, which is where users can provide serialization options to the context
argument of .model_dump()
.
from brand_yml import Brand
brand = Brand.from_yaml_str(
f"""
typography:
base:
size: 18px
"""
)
brand.typography.model_dump(
exclude_none = True,
context={"typography_base_size_unit": "rem"}
)
#> {'fonts': [], 'base': {'size': '1.125rem'}}
(From the example in the docs.)
Often useful in particular for
typography.base.size
.