Socket
Socket
Sign inDemoInstall

variable-replacer

Package Overview
Dependencies
16
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    variable-replacer

The simplest templating engine: only replace variables in files


Version published
Weekly downloads
43
decreased by-4.44%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

node-variable-replacer

The simplest templating engine: replace variables in files

Templating language

Surround variables names by percents. Supports nested variables Works with any text file.

the value of var1 variable is: %var1%
the value of the key1 attr of var2 is %var2.key1%

Replace with values from either inline data or json file(s).

Usage

Command line
npm install -g variable-replacer
variable-replacer sourcepath1 [sourcepath2 sourcepath3] destpath --data=datasource.json [--data-myvarname=value]
Node JS
npm install variable-replacer
require('variable-replacer')({
    source: 'source/path',
    dest: 'dest/path',
    dataSource: 'data.json',
    inlineData: {
        var1 : 'val1',
        var2 : {
        	key1: 'val2'
        }
    }
})

Options

options.source (Mandatory)

Mandatory Type: String or array of String Note: glob pattern supported

Files to process (input files)

options.dest

Mandatory Type: String

Destination file or directory, where output file will be written.

options.dataSource

Optional Type: String or array of String

Path(s) of json file(s) containing source of data for variable replacement.

options.inlineData

Optional Type: Object

Inline source of data for variable replacement

options.variablePattern

Optional Type: String or RegExp

The Regular Expresssion used to match variables. The first group must return the variable path. Defaults to /%([\w._-]+)%/g

options.logLevel

Optional Default: info Type: "debug", "info", "warn", "error", "none"

Change logging level

Contributing

Pull requests are welcome

TODO

  • Add support for inline input and output
  • Add support for reusable replacer
  • Improve error handling and logging

Keywords

FAQs

Last updated on 09 Feb 2018

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc