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.scssEach 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.jsfile exists inside each of your templates. - A valid path to your templates folder is provided.
Setting Up
- Create a folder named
templatesin your project. - Add subdirectories for each template type (e.g.,
plugin,block). - Define your files and variables in each template.
Example of a wpf.config.js file for a plugin:
{
"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:
wpf create-custom --path ./templatesOR, for a global template directory:
wpf create-custom --path ~/.wpf/templatesTips and Best Practices
Organize Templates:
Maintain a clear and consistent folder structure for your templates.Keep Variables Updated:
Ensure that thewpf.config.jsfile 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.
