Automate Template Creation Process

Hi All,

With Blaze, when I wanted to create a new template/component, I will have to create 1 folder (with template name as folder name) and 3 files with same name (js, html & css) with some common template tag and import html and css on js file.

I need to manually create all the above files/folder everytime I need to create a new template/component.

Are there any CLI or better way to create this automatically by just giving name to it? Any tools that I can make such creation template?

Please advice, thank you.

I’m using Scaffs with VS Code. It’s great.

2 Likes

Thank you very much. Looks like exactly what I’m looking for. This gonna save me loads of time… Thanks again.

Hi,

Do you mind share a bit how to get started using the plugin? I read the help file at

After done create those files, scaffs-config.json, template files and folders…

When I try right click and select “Scaffold”, the text box show empty field. The following is my config file.

.scaffs-config.json

{
    "scaffsPaths": [
        "./scaffolds/template"
    ],
    "scaffs": {
        "Template": "./scaffolds/template"
    }
}

~/project/scaffolds/template/.scaffold.json

{
    "variables": [
        "name",
        {
            "prompt": "Enter Template Name",
            "name": "name",
            "optional": false
        }
    ]
}

Am I doing something wrong here? Please advice, thanks.

For me it just …worked. Here’s my “setup”:

// ~/project/.scaffs-config.json
{
    "scaffsPaths": [
        "./.scaffs/"
    ],
    "indention": "  ",
    "header": ""
}
// ~/project/.scaffs/component/.scaffold.json
{
    "variables": [
        "name"
    ]
}

I also get an empty input box when scaffolding, with the different templates selectable below the input. So you should have “template” under the input?

I think the issue here is that you include template in your scaffsPaths.

Ok I’ll try make some changes. Thanks.

I tried remove template from scaffsPaths, I still don’t get “template” under the text box.

What is the purpose of “indention”? Can I just remove it?

Please advice, thank you.

Hi,

I found the problem. The reason it didn’t work for me is because I have 3 separate project folders in 1 workspace. That confused the plugin. I tried at 1 folder workspace and it’s working fine.

Thanks.

I use Scaffs in a monorepo with tens of “projects” in one workspace and it works fine. I just have to keep the scaff configs at root. Glad you got it working!

Ah ya, you’re right. I missed that. Thanks again.

1 Like