Currently, schematics may provide custom functions for use within the context of that schematic by providing a custom_functions.py file that includes functions decorated with register_custom_function; however, in cases where many schematics exist within one large project it would be preferable to have a single place to expose functions within the scope of all child schematics.
A possible solution would be to recursively search for any/all occurrences of custom_functions.py when resolving the full schematic path and to then apply them sequentially. The order here should matter -- highest priority shall be given to the most granular scope (i.e. if an identically-named function is provided at the schematic-level custom_functions.py it should override the global. This is relatively easy to implement by parsing the most-specific file last, which would override the colliding keys within env.globals for the Jinja environment.
Currently, schematics may provide custom functions for use within the context of that schematic by providing a
custom_functions.py
file that includes functions decorated withregister_custom_function
; however, in cases where many schematics exist within one large project it would be preferable to have a single place to expose functions within the scope of all child schematics.A possible solution would be to recursively search for any/all occurrences of
custom_functions.py
when resolving the full schematic path and to then apply them sequentially. The order here should matter -- highest priority shall be given to the most granular scope (i.e. if an identically-named function is provided at the schematic-levelcustom_functions.py
it should override the global. This is relatively easy to implement by parsing the most-specific file last, which would override the colliding keys withinenv.globals
for the Jinja environment.