Skip to content

Make template file source update

Pre-release
Pre-release
Compare
Choose a tag to compare
@devowhippit devowhippit released this 30 Jun 14:32
· 134 commits to main since this release

Make Templates

Migrated make to source template files from the config/make/ directory. Previously template files were stored in the config/make.js file as strings;

const templates = {
  'markup': [
      "/",
      "/ {{ Pattern }}",
      "/",
      "",
      "div class=\"{{ prefix }}{{ pattern }}\""
    ].join("\n"),
  'markdown': [
      "",
      "**Source:** `src/{{ type }}/{{ pattern }}/{{ pattern }}`",
      "",
      "About the {{ Pattern }} {{ type }}.",
    ].join("\n"),
  'styles': [
    ...
  ],
  ...
}

Templates are now sourced from actual files in the config/make/ directory;

config/make/markdown.md
config/make/markup.slm
config/make/readme.md
config/make/view.slm
config/make/script.js
config/make/config.scss
config/make/style.scss

The contents of the files remain the same.

Migration

  • Move contents of the templates object in the config/make.js into newly created files listed above. If you do not wish to create your own templates you can simply omit the file and rely on the framework's defaults.
  • Remove the variable and module.export instance of templates from the config/make.js file.

Other optional suggestions

  • Update the keys in each config/make.js configuration object from views, scripts and styles to their singular view, script and style. This allows you to type npx pttrn make component view when you need to add an extra file to a pattern (slightly easier to remember?).
  • Add 'readme' to the patterns and optional constant so that it isn't created automatically.

Recursive

Make now implements the recursive option for making files. If a directory for a pattern does not exist in a project it will be created.