The main configuration object
The return type for the function
A function that takes path information about file, and returns a value of type T
The full path of the current file
The directory containing the current file
The name of the file
A return value
Represents a response for file path information. Can either be:
T
- static valueT
:(fullPath: string, basedir: string, basename: string) => T
The names of the available helper functions that relate to text capitalization.
These are available for subfolderNameHelper
.
Helper name | Example code | Example output |
---|---|---|
[None] | {{ name }} |
my name |
camelCase |
{{ camelCase name }} |
myName |
snakeCase |
{{ snakeCase name }} |
my_name |
startCase |
{{ startCase name }} |
My Name |
kebabCase |
{{ kebabCase name }} |
my-name |
hyphenCase |
{{ hyphenCase name }} |
my-name |
pascalCase |
{{ pascalCase name }} |
MyName |
upperCase |
{{ upperCase name }} |
MY NAME |
lowerCase |
{{ lowerCase name }} |
my name |
The names of the available helper functions that relate to dates.
Helper name | Description | Example code | Example output |
---|---|---|---|
now |
Current date with format | {{ now "yyyy-MM-dd HH:mm" }} |
2042-01-01 15:00 |
now (with offset) |
Current date with format, and with offset | {{ now "yyyy-MM-dd HH:mm" -1 "hours" }} |
2042-01-01 14:00 |
date |
Custom date with format | {{ date "2042-01-01T15:00:00Z" "yyyy-MM-dd HH:mm" }} |
2042-01-01 15:00 |
date (with offset) |
Custom date with format, and with offset | {{ date "2042-01-01T15:00:00Z" "yyyy-MM-dd HH:mm" -1 "days" }} |
2041-31-12 15:00 |
date (with date from --data ) |
Custom date with format, with data from the data config option |
{{ date myCustomDate "yyyy-MM-dd HH:mm" }} |
2042-01-01 12:00 |
Further details:
We use date-fns
for parsing/manipulating the dates. If you want
more information on the date tokens to use, refer to
their format documentation.
The date helper format takes the following arguments:
(
date: string,
format: string,
offsetAmount?: number,
offsetType?: "years" | "months" | "weeks" | "days" | "hours" | "minutes" | "seconds"
)
The now helper (for current time) takes the same arguments, minus the first one (date
) as it is implicitly
the current date.
The names of all the available helper functions in templates. Simple-Scaffold provides some built-in text transformation filters usable by Handlebars.js.
For example, you may use {{ snakeCase name }}
inside a template file or filename, and it will
replace My Name
with my_name
when producing the final value.
Helper function, see https://handlebarsjs.com/guide/#custom-helpers
Generated using TypeDoc
Create a scaffold using given
options
.Create files
To create a file structure to output, use any directory and file structure you would like. Inside folder names, file names or file contents, you may place
{{ var }}
wherevar
is eithername
which is the scaffold name you provided or one of the keys you provided in thedata
option.The contents and names will be replaced with the transformed values so you can use your original structure as a boilerplate for other projects, components, modules, or even single files.
The files will maintain their structure, starting from the directory containing the template (or the template itself if it is already a directory), and will output from that directory into the directory defined by
config.output
.Helpers
Helpers are functions you can use to transform your
{{ var }}
contents into other values without having to pre-define the data and use a duplicated key.Any functions you provide in
helpers
option will also be available to you to make custom formatting as you see fit (for example, formatting a date)For available default values, see DefaultHelpers.
DefaultHelpers
CaseHelpers
DateHelpers