Enhancing model data

Hello,

I have a model/dictionary as YAML and want to define default values before using the model in several templates.

t_default: bar
p_default: 42
cfg:
h1:
t: foo
h2:
p: 1

Now I want to prepare cfg so that cfg.h1.p == 42 and cfg.h2.t == bar

I now have to use a lot of | default filtering but like to do this only once. As this is related to a role, I would like to put the code in a directory of the role. As far as I understood, library may only hold action modules.

Regards
Mirko