aminehmida / atom-smart-template

Template package for atom editor

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

atom-smart-template package

The package is designed for quick and easy creation of file or multiple files and directories from a template using parameters.

How to use

Use the command "Create files from template" from the context menu of the file tree.

How to create new template

The main file of template is "index.js":

module.exports = {

    name: "Base template",

    directory: false,

    params: [
      { name: "Name", default: "Default name"},
      { name: "Body", default: ""}
    ],

    rules: function(config) {

      return({
        items: [
          { destinationFile: "index.html",           sourceTemplateFile: "index.template"    },
          { destinationFile: "images/someimage.jpg", sourceContentFile: "img/someimage.jpg" }
        ]
      });

    }

}

The rules function has a config parameter which contains the values entered by the user when creating the template. You can use these values to generate the names and content of destination files. Also you can simply copy the files from your template (sourceContentFile) to the target folder without processing.

Optional directory property to template options. If enabled, while creating files from template, there will be a parent directory created as well. It's name will be same as the "Name" parameter set - if available. Otherwise, it'll take the name of the template itself.

About

Template package for atom editor

License:MIT License


Languages

Language:CoffeeScript 93.0%Language:JavaScript 4.6%Language:CSS 2.4%