0.0.12 • Published 10 months ago

codegen-js v0.0.12

Weekly downloads
2
License
ISC
Repository
github
Last release
10 months ago

codegen-js

Utility lib to generate code from handlebars templates

https://handlebarsjs.com/guide/

Install

npm install codegen-js

Use Basic

const cg = require('codegen-js')();
//Path to handlebars template, data, output path
compilePromise = cg.compile('./testDir/template.txt', {name: 'jhon'}, './testDir/res.txt');

//Path file, path to copy file
copyPromise = cg.copy('./testDir/f1.txt', './outDir/f2.txt');

//Path dir, path to copy dir
copyDirPromise = cg.copyDir('./testDir', './outDir');

//Change directories
cg.cd('./inDir', './outDir');
// Copy ./inDir/testDir/f1.txt to ./outDir/d2/f2.txt
copyPromise = cg.copy('./testDir/f1.txt', './d2/f2.txt');

//Path to handlebars template: ./inDir/testDir/template.txt
compilePromise = cg.compile('./testDir/template.txt', {name: 'jhon'}, './testDir/res.txt');

//Can omit the outputPath, will write to ./outDir/testDir/template.txt
compilePromise = cg.compile('./testDir/template.txt', {name: 'jhon'});

Customize Handlebars

const cg = require('codegen-js')

cgConstructor.Handlebars.registerHelper('loud', function (aString) {
  return aString.toUpperCase()
})
// https://handlebarsjs.com/guide/expressions.html#helpers

Faster copyDir with linux

const cg = require('codegen-js')({linux: true});
0.0.12

10 months ago

0.0.11

3 years ago

0.0.10

3 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

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