Code Monkey home page Code Monkey logo

scaffr's Introduction

Scaffr

A simple code scaffolding tool to speed up repetitive coding tasks.

Installation

Install globally

npm install -g scaffr

Use without installing

npx scaffr /path/to/template/folder /path/to/destination

Usage

# Using templates from local machine
scaffr /path/to/template/folder /path/to/destination

# Or using zip files over HTTP
scaffr https://example.com/my-template.zip /path/to/destination

# Example:
# scaffr ~/templates/project-template ./HelloWorld

Creating a template

A template can have any number/kind of files. Scaffr will then interpret contents and file names when it encounters template syntax.

For example:

scaffr ~/templates/project-template ./HelloWorld

will result in:

Source file Destination file
~/templates/project-template/{{name}}.js ./HelloWorld/HelloWorld.js

The templating engine

Scaffr uses Lodash's _.template function to process templates. Variables use {{ and }} for interpolation.

Example:

// {{name}}.js
const hello = () => 'Hello, from {{name}}!';

export default hello;

will be compiled into:

// HelloWorld.js
const hello = () => 'Hello, from HelloWorld!';

export default hello;

For more informations on templating please refer to Lodash documentation.

Variables

The following list of variables is available for every file:

Variable Description
name Folder name. Example: if destination path is /path/to/MyProject, name would be MyProject
destPath Destination full path
templatePath Template full path
_ Lodash library passed in for convenience

Example templates

A sample template can be found in the /examples folder.

scaffr's People

Contributors

abdelilah avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.