Skip to content
On this page

Custom Templates Guide

Overview

WPF CLI allows you to use custom templates to generate plugins, blocks, or other structures. This feature is designed to give you flexibility and efficiency by reusing predefined templates tailored to your needs.

How It Works

Custom templates should be stored in a specified folder with the following structure:

your-personnal-path/templates/
├─ plugin/
│  ├─ wpf.config.js
│  ├─ src/
│  │  ├─ index.js
│  │  └─ style.css
├─ block/
│  ├─ wpf.config.js
│  ├─ src/
│  │  ├─ editor.js
│  │  └─ editor.scss

Each folder represents a template, and wpf.config.js contains the custom variables for Mustache rendering.

Prerequisites

Before using custom templates, ensure the following:

  • The wpf.config.js file exists inside each of your templates.
  • A valid path to your templates folder is provided.

Setting Up

  1. Create a folder named templates in your project.
  2. Add subdirectories for each template type (e.g., plugin, block).
  3. Define your files and variables in each template.

Example of a wpf.config.js file for a plugin:

json
{
  "pluginName": "CustomPlugin",
  "pluginVersion": "1.0.0",
  "pluginDescription": "A custom plugin template",
  "pluginAuthor": "Your Name"
}

CLI Commands

Generate from Custom Templates

To use a custom template, run:

bash
wpf create-custom --path ./templates

OR, for a global template directory:

bash
wpf create-custom --path ~/.wpf/templates

Tips and Best Practices

  • Organize Templates:
    Maintain a clear and consistent folder structure for your templates.

  • Keep Variables Updated:
    Ensure that the wpf.config.js file includes all necessary fields.

  • Test Regularly:
    Run your templates frequently to identify missing configurations or potential errors.

Troubleshooting

Common Errors

  • Path does not exist: Ensure the path to the templates folder is correct.
  • No templates found: Verify the folder structure and ensure templates are properly added.

Released under the MIT License.