1.0.1 • Published 5 years ago

phjs v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

PHJS.js

npm NPM npm npm bundle size

PHJS is a small library for javascript templating. PHJS was created as additional module for Rapidly CLI, but now it is available as independent package, to develop and maintain.

Usage

You can install this package via npm, using command:

npm i phjs

PHJS is using specific syntax, to provide a placeholders for variables in .js files.

<%= %>

NOTE: your code editor will probably complain about this syntax, but you can ignore it.

Now you can create your .js template file:

// userClass.js
class <%= className %> {}

Then import PHJS and use render function:

// index.js
const phjs = require('phjs');

const vars = {
  className: 'User', //key name must be the same like in template file
};

// This function will create output.js file in your root directory. It takes 3 arguments: path to src file, destination of a new file and variables.
phjs.renderAndCreate('./userClass.js', 'output.js', vars);

Output:

// output.js
class User {}
1.0.1

5 years ago

1.0.0

5 years ago