Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jatg

Package Overview
Dependencies
Maintainers
0
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jatg

Just Another Template Generator

  • 0.0.1
  • unpublished
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
decreased by-40%
Maintainers
0
Weekly downloads
 
Created
Source

JATG - Just Another Template Generator

Low configuration CLI to generate files based on templates.

Setting Up

  1. Create the templates.json configuration file
  2. Create your template files
  3. Generate the files by running jatg

Configuration

The configuration is a JSON file named templates.json. Here's an example:

{
  "templates": [
    {
      "name": "my-awesome-template",
      "sourcePaths": ["./templates"],
      "outputPath": "./src/modules",
      "variables": [
        {
          "variable": "name",
          "name": "Module Name"
        }
      ]
    }
  ],
  "$schema": "node_modules/jatg/templates.schema.json"
}

The format of this file is documented through the TemplateConfiguration TypeScript interface and the JSON Schema. Refer them for a list of all possible properties.

Variables

A template can have multiple variables. Those can be defined in the configuration and can be used to make template contents and file names dynamic.

The syntax is the variable name surrounded by percentages (%variable_name%) and the value can be formatted through special functions, separated by dots (%variable_name.upper%).

For the variable named entity and the value user-post, here are a few examples:

TemplateResultWhat is hapenning?
%entity%user-postprints the variable value as is
%entity.upper%USER-POSTprints the variable formatted value in uppercase
%entity.plural.upper%USER-POSTSprints the variable value formatted in plural and in uppercase
%entity.plural.dotCase.upper%USER.POSTSprints the variable value formatted in plural, in dot case and in uppercase

Variables can be used in template file contents, the template file name and the configuration outputPath.

Formatting Functions

Basic

These are based on the basic string functions included in JavaScript.

FunctionResult
upperTWOWORDS
lowertwowords
Change Case

These functions use change-case under the hood.

FunctionResult
camelCasetwoWords
capitalCaseTwo Words
constantCaseTWO_WORDS
dotCasetwo.words
kebabCasetwo-words
noCasetwo words
pascalCaseTwoWords
pascalSnakeCaseTwo_Words
pathCasetwo/words
sentenceCaseTwo words
snakeCasetwo_words
trainCaseTwo-Words
initialsTW
Pluralize

These functions use pluralize under the hood.

FunctionResult
pluraltwoWords
singulartwoWord

Running

Run the generation by simply running the command below.

jatg

You can also specify options, such as picking a specific template:

jatg --template my-awesome-template

For a list of options, run jatg --help.

FAQs

Package last updated on 07 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc