Skip to content

A general-purpose project scaffolding tool inspired by cookiecutter

License

Notifications You must be signed in to change notification settings

block/scaffolder

A general-purpose project scaffolding library and tool inspired by cookiecutter

stability-experimental Go Reference CI


Scaffolder evaluates the scaffolding files at the given desScaffolder evaluates a template of directories and files into a destination using JSON context using the following rules:

  • Templates are evaluated using the Go template engine.
  • Both path names and file contents are evaluated.
  • If a file name ends with ".tmpl", the ".tmpl" suffix will be removed.
  • If a file or directory name evalutes to the empty string it will be excluded.
  • If a file named "template.js" exists in the root of the template directory, all functions defined in this file will be available as Go template functions.
  • Directory and file names in templates can be expanded multiple times using the "push" function. This function takes two arguments, the file/directory name and the context to use when evaluating templates within the file/directory.
  • The following functions are available as Go template functions: "snake", "screamingSnake", "camel", "lowerCamel", "kebab", "screamingKebab", "upper", "lower", "title",

For example, given the following files and directories as the template:

template/
  {{ range .modules }}{{ push .name  . }}{{ end }}/
    file.txt

And the context "context.json":

{
  "modules": [
    {"name": "module1", "path": "path1"},
    {"name": "module2", "path": "path2"}
  ]
}

Running scaffolder with:

scaffolder --json context.json --template template --dest dest

The output "dest" directory will contain the following files and directories:

module1/
  file.txt
module2/
  file.txt

About

A general-purpose project scaffolding tool inspired by cookiecutter

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published