cookiecutter - 如果cookiecutter模板中未定义变量,如何设置默认值?
问题描述
我正在使用 cookiecutter 1.7.3
我想要一种方法来设置默认值,以防模板中存在未定义的变量。
我试过的
在 jinja 中使用默认过滤器
"github_username": "{{ cookiecutter.github_repo.owner.login|default('Your GitHub username here', true) }}"
或布尔值
"github_username": "{{ cookiecutter.github_repo.owner.login or 'Your GitHub username here' }}"
这些都不起作用。我仍然在模板错误中得到未定义的变量。
可以指教吗?
解决方案
推荐阅读
- jquery - 如何在asp.net核心项目中使用ajax填充下拉列表树嵌套数据?
- django - 获取模型类中“created_by”字段的当前用户
- sql - SQL - 选择多个/所有列但排除一个或两个特定列中的重复数据?
- docker - 如何获取要在应用程序内部使用的 kubernetes pod 或部署 IP
- angular - Angular 中的 Promise:直接返回时的无限调用
- javascript - Angular 下载大块
- javascript - React js 状态和生命周期
- javascript - 是否可以在浏览器(前端)中安装 Joi 验证而不需要 babeling?
- javascript - 如何在滚动上实现jquery加载
- c# - 从 VSIX 应用程序连接到 Azure DevOps 失败