Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>New From Nunjucks TemplateNew to Visual Studio Code? Get it now.
New From Nunjucks Template

New From Nunjucks Template

shilim

|
7 installs
| (0) | Free
Creates a new file/folder structure from nunjucks template
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

New From Nunjucks Template

version LICENSE Coverage Status

English | 简体中文

Table of Contents

Click me to Open/Close the directory listing
  • Marketplace
  • Introductions
  • Features
  • Template Preparation
  • Usage
  • Recommend
  • ChangeLog
  • License

Marketplace

Visual Studio Marketplace

Introductions

Creates a new file/folder structure from nunjucks template

Features

  • Generate files through nunjucks templates
  • Support global parameters and local parameters
  • Support creating callbacks before and after

Template Preparation

Template Directory Structure

.templates                          
├─ template_file         (Template Name) [Single File Template]
│  └─ @@config.js        (Template Replacement Parameter List Configuration File)
│  └─ @@params.js        (Template Replacement Parameter Object) [optional]
│  └─ file_name.js       (Template File)               
├─ template_folder       (Template Name) [Folder Template]
│  └─ @@config.js        (Template Parameter List Configuration File)
│  └─ component_name     (Template Folder)    
│     └─ file_name.css     
│     └─ file_name.html 
│     └─ file_name.js 
├─ callback.js           (Callback)    
└─ global.js             (Global Parameter)

@@config.js

exports.fileParams = ["file_name"];
exports.templateParams = [];

@@params.js

module.exports = () => {
  return {
    fileParams:{
      file_name: 'helloworld',
    },
    templateParams:{
      content: 'hello',
    }
  };
};

@@callback.js

exports.newFolder = (path, params) => {
  console.log(path,params);
};

exports.newFile = (path) => {
  console.log(path);
};

exports.finish = () => {
  console.log("finish");
};

Template Language

use nunjucks

Usage

Example of Creating WeChat Mini Program Code with Templates

newTemplate

Example of Creating WeChat Mini Program Code with Templates and Auto registry app.json

newTemplateWithCallback

Recommend

  • template-new-cli CLI to new files by nunjucks template
  • snippets-viewer Snippets Viewer for Visual Studio Code

ChangeLog

ChangeLog

License

License MIT

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft