Attributes
The meta of a template document is called Attributes. Several options can be combined for flexible file generation.
Options#
List of attributes that can be specified with Front Matter.
key | type | description |
---|---|---|
name (required) | string | Name of template. |
root (required) | string | The directory as the starting point of the output destination. |
output (required) | string string[] | Directory starting from root and being a destination candidate. You can use glob syntax. (see globby document) |
ignore | string[] | Directory to exclude from candidate output destination. You can use glob syntax. (see globby document) |
questions | object | Message to display when accepting input. |
Questions#
questions
is a protocol for accepting the necessary input for the template. scaffdog provides several options so that you can define a suitable question type.
Free text#
Invokes the most commonly used prompt that accepts strings.
questions:# syntax sugarvalue1: 'Please enter any text.'# with messagevalue2:message: 'Please enter any text.'# with default valuevalue3:message: 'Please enter any text.'initial: 'scaffdog'

Boolean#
Invoke a prompt that accepts a Boolean.
questions:# basicbool1:confirm: 'Do you need something?'# with default valuebool2:confirm: 'Do you need something?'initial: false

Choice#
Invokes a prompt to select a single value from a list.
questions:# basicvalue1:message: 'Please select a value.'choices:- 'A'- 'B'- 'C'# with default valuevalue2:message: 'Please select a value.'choices:- 'A'- 'B'- 'C'initial: 'B'

Array#
Invokes a prompt to select multiple selections from the list.
questions:# basicvalue1:message: 'Please select a value.'multiple: truechoices:- 'A'- 'B'- 'C'# with default valuevalue2:message: 'Please select a value.'multiple: truechoices:- 'A'- 'B'- 'C'initial: ['B']

Conditional Prompt#
If the result of the expression in the if
field is true
, Prompt is invoked. If it false
, skip Prompt and assign initial values. The initial value is assigned to the initial
field if it exists. If not, a zero value is assigned according to the Prompt type.
questions:name:message: 'Please enter a component name.'# Invokes confirm prompt only when input includes "Form".test:if: contains(inputs.name, 'Form')confirm: 'Do you need a test?'
This is useful when you want to use a Prompt that is only needed for some use cases in the target file.
Last edited on