Replies: 3 comments 1 reply
-
This is currently not possible but has been discussed before in #1050. We're open to a contribution in case you're interested. 🙂 |
Beta Was this translation helpful? Give feedback.
-
Note this is possible via ContextHook code (see Altering the context), as I've been playing around with. Bit hacky but works, if you're comfortable having to use from copier_templates_extensions import ContextHook
class ContextUpdater(ContextHook):
def hook(self, context):
# Find the dst_path in config object
copier_conf = context["_copier_conf"]
dst_path = copier_conf["dst_path"] # Note it's a pathlib.Path type here
microservice_dir = dst_path.name # Because of the Path type!
module_name = microservice_dir.replace('-service', '').replace('-', '_')
return {"microservice_directory": microservice_dir, "microservice_module": module_name } I've been using (abusing) that in my template layering experiments to reload the |
Beta Was this translation helpful? Give feedback.
-
FWIW, while executing tasks, the CWD is the destination path. There's also #1271 about dynamic generation of folders or files. |
Beta Was this translation helpful? Give feedback.
-
I want to have a template create subfolders based on the basename of the destination folder. Is this already possible somehow? I tried with
_copier_answers._dst_path
, but that is not available until all questions have been answered.I'd like to be able to do something like this:
And then use both variables in my template.
Beta Was this translation helpful? Give feedback.
All reactions