Open chason-choate opened 2 years ago
Have you looked at the interceptors (https://mockintosh.io/#interceptors) ?
This is, in a way, related to #164. Giving users of the service the ability to inject new template methods would be a large usability boon as they could be iterated upon within the UI editor, etc. (Their usage, I mean. The implementation could be unit tested elsewhere if needed)
I did not see interceptors previously. Good to know they exist but they feel too general for this use-case. Interceptors seem to lack the interactivity you get from editing config/templates/etc. through the UI.
As we expand on our usage of mockintosh we need the ability to provide custom template methods to do more complicated actions. For instance, we have a use-case where we want to inject certain complicated structures into objects based on some conditions.
FWIW we are using the docker container and happy to build out new python methods. We just need an easy way to wire them into Mockintosh. At the moment we are mounting copies of the
hbs/methods.py
andtemplating.py
files into the container with custom code.I have limited python knowledge but i think something like the following could be useful.
MOCKINTOSH_TEMPLATE_METHODS_DIR
. b. OR additional yaml configuration that specifies either a directory or specific files to load?inject_methods() -> list[Callable]
method. These defined methods can be merged with the existing methods in thetemplating.py
file.