1.2.0 • Published 2 years ago

@ztwx/auto-template v1.2.0

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Auto Template

Simple use

import {ManageTempalteWatchDir}  from "@ztwx/auto-template";
const path=require("path");

new MangeTemplateWatchDir().watch(
  path.join(process.cwd(),"src")
)

Auto watch dir

custom template plugin

import {TemplatePlugin,BaseData,ManageTempalteWatchDir} from "@ztwx/TemplatePlugin";

class MyTemplatePlugin implements TemplatePlugin{
    pluginName:string="myTemplatePlugin";
    version:string="1.0.0";
    // The `yourTemplateDir` will be the template dir path
    templatePath:string=path.join(xxx,"yourTemplateDir");

    //active template when dirname end with "myComponent"
    activeTemplate(dirName:string):boolean{
        return dirName.endsWith("myComponent");
    }
    handleTemplateSource(data:TemplateBaseData){
        return {
            "tp_name":"your custom name",
        }
    }
}

const manageTemplateWatchDir=new MangeTemplateWatchDir();
manageTempalteWatchDir.addPlugin(new MyTemplatePlugin());

manageTemplateWatchDir.watch(...);

yourTemplateDir

  • one.js.j2
console.log("hello ${tp_name}")

${tp_name} will replace to your custom name. and place it in the newly created directory with name one.js

Watch Cli

npx ztwx-autoTp <dirpath>
1.2.0

2 years ago

1.1.0

3 years ago

1.0.0

3 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago