Giter Club home page Giter Club logo

templagen's Introduction

TemplaGen logo

TemplaGen

Badge Wiki

Configure once create everywhere.

How to use extension?

  • Install extension.
  • Right click on any folder slecet TemplaGen | Template Maker.
    • U can also write TemplaGen | Template Maker in command plaettte.
    • Then select the path u want the template to be in.
  • Select template u want for example Flutter clean code.
  • You're done.

Community

  • Ready to use Templates

  • How to use templates?

    • Clone repo on your local machine.
    • Copy templates folder path to templagen -> Templates Folder Path in vscode settings.
  • Share your templates with community.

    • Create custom template then make pull request to share with community.

How to setup your own template?

Folder way

  • First

    • Create Folder for templates anywhere on your device.
    • Copy its path.
    • Open vscode settings
    • search for templagen
    • Look for templatesFolderPath and paste path in it.
  • Second

    • Create new Folder with any name you want.

    • Make templagen.json inside the Folder

    •     {
            "name":"Flutter Bloc"
            "needSubDir": true,
            "subDirNameCase": "snakeCase",
            "foldersFilesNamesReplacer": [
              {
                "case": "snakeCase",
                "nameToReplace": "key",
                "useSubDirName": true
              }
            ],
            "filesContentReplacer": [
              {
                "case": "snakeCase",
                "nameToReplace": "<{key_sc}>",
                "useSubDirName": true
              },
              {
                "case": "pascalCase",
                "nameToReplace": "<{key}>",
                "useSubDirName": true
              }
            ]
          }
      
      
    • Create any folders or files in the folder as you like.

Json way

  • Open vscode settings

  • search for templagen

  • Dir Templates edit in settings.json

  • for example:

    {
      "name": "Flutter Clean Code",
      "needSubDir": true,
      "subDirNameCase": "snakeCase",
      "dirs": {
        "data": [
          "data_source",
          "models",
          "repository"
        ],
        "domain": [
          "entities",
          "use_cases",
          "repository"
        ],
        "presentation": [
          "components",
          "controller",
          "screens"
        ]
      }
    }
    

The output dir will be like

|- <subDirName>
    |- data
    |  |- data_source
    |  |- models
    |  |- repository
    |- domain
    |  |- entities
    |  |- use_cases
    |  |- repository
    |- presentation
    |  |- components
    |  |- controller
    |  |- screens

Docs

name

  • is the name of template to be select when create template

  • JsonTemplate name of the template

  • FolderTemplate overwrite folder name if not empty or whitespace

"name": "Flutter Clean Code"

needSubDir

  • check wheter the template directories required subDir to created in or not.
  • if true you'll be asked for subDir name.
  • if false the dirs will be created directly.
"needSubDir": true,

subDirNameCase

  • the name case you want

  • "needSubDir": "snakeCase",
    

foldersFilesNamesReplacer

  • define keys in dirs and files name to be replaced later

  • FolderTemplate only

  •    {
         "foldersFilesNamesReplacer": [
           {
             "case": "snakeCase",
             "nameToReplace": "key",
             "useSubDirName": true
           }
         ]
       }
    

filesContentReplacer

  • define keys inside files content to be replaced later

  • FolderTemplate only

  • 
         {
           "filesContentReplacer": [
             {
               "case": "snakeCase",
               "nameToReplace": "<{key_sc}>",
               "useSubDirName": true
             },
             {
               "case": "pascalCase",
               "nameToReplace": "<{key}>",
               "useSubDirName": true
             }
           ]
         }
    

dirs

  • the dirs which will be created

JsonTemplate

  • use to define yor template folder structure.
  • U can use long path to define folders in folder like:
  • Fold/01/02/03/04
  • This will create Directory Fold and create 01 in it and create 02 in 01 and so on.

FolderTemplate

  • From v0.0.6 and above u can use this in templagen.json note that
  • Folders is the refrence.
  • Any folder not in dirs will be added automatically when create the template.
  • Any path defined in dirs but not in folder you will be asked whether to create its directory or remove paths from dirs in templagen.json.
  • You should make folderTemplateAutoGenerateDirs true from vscode settings.

    "dirs": {
      "data": [
        "data_source",
        "models",
        "repository"
      ]
    }

Replacer schema

  • casethe case of the name to replace nameToReplace with.
  • nameToReplacethe key you define to be replaced.
  • useSubDirName choose wheter to use the subDirName or not
  • if set to false or needSubDir set to false you will be asked to enter a name to replace the key with

{
"case": "snakeCase",
"nameToReplace": "<{key_sc}>",
"useSubDirName": true
},

Available cases

  • The following docs of cases copied from change-case packages
  • camelCase
    • Transform into a string with the separator denoted by the next word capitalized.
    • test string |-> testString
  • capitalCase
    • Transform into a space separated string with each word capitalized.
    • test string |-> Test String
  • constantCase
    • Transform into upper case string with an underscore between words.
    • test string |-> TEST_STRING
  • dotCase
    • Transform into a lower case string with a period between words.
    • test string |-> test.string
  • headerCase
    • Transform into a dash separated string of capitalized words.
    • test string |-> Test-String
  • noCase
    • Transform into a lower cased string with spaces between words.
    • testString |-> test string
  • paramCase
    • Transform into a lower cased string with dashes between words.
    • test string |-> test-string
  • pascalCase
    • Transform into a string of capitalized words without separators.
    • test string |-> TestString
  • pathCase
    • Transform into a lower case string with slashes between words.
    • test string |-> test/string
  • sentenceCase
    • Transform into a lower case with spaces between words, then capitalize the string.
    • testString |-> Test string
  • snakeCase
    • Transform into a lower case string with underscores between words.
    • test string |-> test_string

Extension settings

General

dirTemplates

  • Json templates definitions.

templatesFolderPath

  • Path of folder that contain your templates.

folderTemplateAutoGenerateDirs

  • Auto generate dirs in templagen.json useful in case your want to save your folder templates on Github.

List

listShowTemplateNameAsPath

  • When activated it will group templates instead of being separated in list.

listNameSeparatedBy

  • When listShowTemplateNameAsPath is set to true the text used to represent nested paths.

listShowTemplatesGrouped

  • When templagen.json name not exist show template name as the path it exist in.

templagen's People

Stargazers

 avatar  avatar  avatar

Watchers

 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.