node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »


{--} CodebotJS

NPM Version Build Status Downloads Dependency Status License

This project is under development

Codebot is the easy way to make applications from templates.

The idea is that you need to write the code one time, then use a model.

Think an application, write it as templates and then use to make multiple apps changin the model, if you improve something, change the templates and every app will take the benefit.


npm i --save-dev codebot


Codebot use ejs as default template engine

If the src is not defined on /path/from/module/codebot.json, the templates will be searched on the /path/from/module/src/ folder

Directives to filenames and folders

directive usage description
# #layername layer/folder names
@ @filename automatic file
! !filename injector file (not supported yet)
${} ${target} dynamics names
$this ${$this} current dynamic name from parent


character usage description
l $l{target} write the target as lowerCase*
u $u{target} write the target as upperCase*
c $c{target} write the target as camelCase*
s $s{target} write the target as snakeCase*
k $k{target} write the target as kebabCase*
p $p{target} write the target as capitalize*

*please see the lodash documentation

Configuration file

// codebot.json
  "src": "the_source/",
  "ignore": [ "some_file/expression" ]

NOTE: you can set the config into the package.json like

  "name": "my-awesome-template",
  "codebot": {
    "src": "the_source/"


import codebot from 'codebot';
let model = {
  foo: 'bar'
let ops = {
  modules: [
  output: '/path/to/',
  model: model
  .then(results => {
    // all tamplates are processed
    // show the trees
    results.modules.forEach( m => {
      console.log(m.toString(true, 'source-tree'));
    results.modules.forEach( m => {
      console.log(m.toString(true, 'output-tree'));
  .catch(err => {

The inject file example (not supported yet)

the transpiler match a full line with the codebot:inject thing

  // !some.js
  // inject:codebot
  // endinject
  // !some.html
  <!-- inject:codebot -->
  <h1><%= $this.title %></h1>
  <!-- endinject -->

Usage with gulp

npm i --save-dev gulp-codebot
var codebot = require('gulp-codebot');
var modules = [
    .pipe(codebot({ modules: modules }))


  layer: {
    'app': './client/app',
    'routes': './server/routes'
  target: {
    'actor': { 
      plurals: 'actors',
      view: {
        'add': {/*view stuff*/}
    'director': { 
      plurals: 'directors',
      view: {
        'add': {/*view stuff*/}
    'movie': { 
      plurals: 'movies',
      view: {
        'add': {/*view stuff*/},
        'edit': {/*view stuff*/},
        'search': {/*view stuff*/},

Templates example

// /path/from/angular/src/
- #app
  - ${target}
    - @${$current}.controller.js
    - @${$current.view}.html
    - !config.js
  - @app.config.js
  - app.js
// /path/from/api/src/
- #routes
  - @${target.plurals}.js

The output

./client/app/actor/actor.controller.js       // writed every time
./client/app/actor/config.js                 // writed/injected every time
./client/app/actor/add.html                  // writed every time
./client/app/director/director.controller.js // writed every time
./client/app/director/config.js              // writed if the output is not exists
./client/app/director/add.html               // writed every time
./client/app/movie/movie.controller.js       // writed every time
./client/app/movie/config.js                 // writed if the output is not exists
./client/app/movie/add.html                  // writed every time
./client/app/movie/edit.html                 // writed every time
./client/app/movie/search.html               // writed every time
./client/app/app.config.js                   // writed every time
./client/app/app.js                          // writed if the output is not exists
./server/routes/actors.js                    // writed every time
./server/routes/directors.js                 // writed every time
./server/routes/movies.js                    // writed every time


MIT © Delmo