DKCutter supports the concept of private variables within your dkcutter.json
configuration. These variables are intended for internal use within your templates and hooks and are not exposed to the user as prompts during project generation.
To define a private variable, simply prepend an underscore (_
) to its name in your dkcutter.json
file.
Consider the following dkcutter.json
configuration:
When DKCutter processes this configuration:
projectName
._privateSlug
variable will be automatically calculated based on the provided projectName
using the Nunjucks template {{ projectName|lower|replace(' ', '-') }}
._privateSlug
.If the user accepts the default value for projectName
("Really cool project"), the resulting context available to your templates and hooks will be:
Private variables are useful for:
By using private variables, you can create more sophisticated and streamlined DKCutter templates, improving the user experience and automating complex configuration tasks.