@devtea2026/odit-voluptas-rerum-ea

2.2.23 • Public • Published

@devtea2026/odit-voluptas-rerum-ea

Build and Test NPM version NPM

Minimal templates for Node.js

Installation

npm install @devtea2026/odit-voluptas-rerum-ea

Usage

const compile = require('@devtea2026/odit-voluptas-rerum-ea');

const compiled = compile('filedir/filename.ct', { name: 'John' }); // filepath and variables

Full example

├── root
│   ├── index.js
│   └── template.ct # template file you can use any extension
// index.js
const compile = require('@devtea2026/odit-voluptas-rerum-ea');

const compiled = compile('template.ct', { name: 'John' }); // you can pass file content as third argument 
console.log(compiled); // you can also write to a file or do whatever you want with the compiled template
<!-- template.ct -->
<h1>Hello, ${name}!</h1>
<h2>How are you? ${capitalize(name)}</h2>
<h3>Lowercase: ${lowercase(name)}</h3>
<!-- output -->
<h1>Hello, John!</h1>
<h2>How are you? John</h2>
<h3>Lowercase: john</h3>

Functions

  • capitalize(string) - Capitalizes the first letter of a string
  • lowercase(string) - Converts a string to lowercase
  • uppercase(string) - Converts a string to uppercase
  • pluralize(string) - Change the word to its plural
  • singularize(string) - Change the word to its singular
  • capPluralize(string) - capitalize + pluralize
  • capSingularize(string) - capitalize + singularize
  • time() - return timestamp

Notes

  • You can't provide whitespace in the function name, so capitalize (name) won't work. You can use capitalize(name) instead.
  • ${ name} won't work. You can use ${name} instead.
  • You can use any extension for the template file, but it's recommended to use .ct for compile-template files.

Readme

Keywords

Package Sidebar

Install

npm i @devtea2026/odit-voluptas-rerum-ea

Weekly Downloads

387

Version

2.2.23

License

MIT

Unpacked Size

30.9 kB

Total Files

67

Last publish

Collaborators

  • quinterochris100