npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

variable-replace

v1.6.0

Published

The simplest templating engine: only replace variables in files

Downloads

5

Readme

node-variable-replace

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-replace
variable-replace sourcepath1 [sourcepath2 sourcepath3] --dest=destpath --data=datasource.json [--data-myvarname=value]
Node JS
npm install variable-replace
require('variable-replace')({
    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

Forked Project

This project is forked from https://www.npmjs.com/package/variable-replacer.

The purpose of the fork was to introduce the following features :

dest argument : allow to clearly separate and make it optionnal.

Now when no argument is provided for dest, the dest path is equal to file source path.

Contributing

Pull requests are welcome

TODO

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