{--} CodebotJS
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.
Install
npm i --save-dev codebot
Templates
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 |
Modifiers
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/" ...
Usage
; let model = foo: 'bar'; let ops = modules: '/path/from/templates/module1' 'path/from/templates/module2' output: '/path/to/' model: model; ;
The inject file example (not supported yet)
the transpiler match a full line with the codebot:inject
thing
// !some.js // inject:codebot console; // endinject
// !some.html <!-- inject:codebot --> <%= $this.title %> <!-- endinject -->
Usage with gulp
npm i --save-dev gulp-codebot
var codebot = ; var modules = '/path/from/templates/module1' '/path/from/templates/module2'; gulp ;
Example
//model.json 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 - @$$currentcontrollerjs - @$$currentviewhtml - !configjs - @appconfigjs - appjs
// /path/from/api/src/- #routes - @$targetpluralsjs
The output
/client/app/actor/actorcontrollerjs // writed every time/client/app/actor/configjs // writed/injected every time/client/app/actor/addhtml // writed every time /client/app/director/directorcontrollerjs // writed every time/client/app/director/configjs // writed if the output is not exists/client/app/director/addhtml // writed every time /client/app/movie/moviecontrollerjs // writed every time/client/app/movie/configjs // writed if the output is not exists/client/app/movie/addhtml // writed every time/client/app/movie/edithtml // writed every time/client/app/movie/searchhtml // writed every time /client/app/appconfigjs // writed every time/client/app/appjs // writed if the output is not exists /server/routes/actorsjs // writed every time/server/routes/directorsjs // writed every time/server/routes/moviesjs // writed every time
License
MIT © Delmo