我希望为我们的内部项目创建一个模板。
项目的布局包含可变数量的子文件夹。
我想在某个配置文件中指定要创建的子文件夹。 例如,我有以下文件夹结构:
配置文件应该有这样的内容:
项目的布局包含可变数量的子文件夹。
我想在某个配置文件中指定要创建的子文件夹。 例如,我有以下文件夹结构:
my_project
|
|___ Tables
| |
| |__ Table1 <--- The folders I would like to create
| |__ Table2 <---|
| |__ Table3 <---|
|
|___ Other_folders
配置文件应该有这样的内容:
配置文件应该有类似这样的内容:
{
"prj_name": "my_project",
"tables": ["Table1", "Table2", "Table3"]
}
我尝试创建以下结构:
{{cookiecutter.prj_name}}
|
|___ Tables
| |
| |__ {% for table in cookiecutter.tables %}{{table}}{% endfor %}
|
|___ Other_folders
将提到的配置添加到cookiecutter.json
中。
我使用了--no-input
运行了cookiecutter,结果只有一个子文件夹(Table1)。
还尝试使用以下文件夹名称:{% for table in cookiecutter.tables.keys() %}{{table}}{% endfor %}
使用以下配置:
{
"prj_name": "my_project",
"tables": {
"table1": "table1",
"table2": "table2",
"table3": "table3"
}
}
输出仍是一个单独的子文件夹(Table2Table1Table3)
有什么办法可以实现所需的结构吗?