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

chalk-template

Package Overview
Dependencies
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chalk-template - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

index.d.ts

114

package.json
{
"name": "chalk-template",
"version": "0.1.0",
"description": "",
"email": "simon.mollweide@web.de",
"author": "Simon Mollweide <simon.mollweide@web.de>",
"url": "https://github.com/smollweide/chalk-template",
"repository": {
"type": "github",
"url": "https://github.com/smollweide/chalk-template"
},
"main": "chalk-template.js",
"bugs": {
"url": "https://github.com/smollweide/chalk-template/issues"
},
"preferGlobal": false,
"private": false,
"license": "MIT",
"homepage": "http://smollweide.github.io/chalk-template/",
"scripts": {
"test": "node_modules/.bin/mocha test.js",
"lint": "npm run lint:js",
"lint:js": "node_modules/.bin/eslint **/*.js"
},
"engines": {
"node": ">= 4"
},
"keywords": [
"cli-app",
"cli",
"color",
"colour",
"colors",
"terminal",
"console",
"string",
"str",
"ansi",
"style",
"styles",
"tty",
"formatting",
"rgb",
"256",
"shell",
"xterm",
"log",
"logging",
"command-line",
"text",
"template",
"tpl"
],
"devDependencies": {
"mocha": "3.2.0"
},
"dependencies": {
"@namics/eslint-config": "2.1.0",
"chalk": "1.1.3",
"eslint": "3.13.1",
"eslint-plugin-import": "2.2.0",
"for-in": "0.1.6"
}
"name": "chalk-template",
"version": "0.2.0",
"description": "Terminal string styling with tagged template literals",
"license": "MIT",
"repository": "chalk/chalk-template",
"funding": "https://github.com/chalk/chalk-template?sponsor=1",
"type": "module",
"exports": "./index.js",
"engines": {
"node": ">=12"
},
"scripts": {
"test": "xo && ava test/index.js && cross-env FORCE_COLOR=0 ava test/no-color.js && cross-env FORCE_COLOR=3 TERM=dumb ava test/full-color.js && tsd"
},
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"chalk",
"template",
"templates",
"templating",
"ansi",
"styles",
"color",
"colour",
"colors",
"terminal",
"console",
"string",
"tty",
"escape",
"formatting",
"rgb",
"256",
"shell",
"xterm",
"log",
"logging",
"command-line",
"text"
],
"dependencies": {
"chalk": "^4.1.2"
},
"devDependencies": {
"ava": "^3.15.0",
"cross-env": "^7.0.3",
"tsd": "^0.18.0",
"xo": "^0.45.0"
}
}

@@ -1,39 +0,62 @@

# chalk-template [![Build Status](https://img.shields.io/travis/smollweide/chalk-template/master.svg)](https://travis-ci.org/smollweide/chalk-template)
# chalk-template
> Simple and easy to use template engine for chalk
> Terminal string styling with [tagged template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates)
<img src="https://cloud.githubusercontent.com/assets/2912007/22125570/7e92454e-de94-11e6-9398-d5136f498cb1.png" width="631">
## Install
```console
$ npm install --save chalk-template
```sh
npm install chalk-template
```
## Usage
```js
const chalk = require('chalk');
const chalkTemplate = require('chalk-template');
import chalkTemplate from 'chalk-template';
import chalk from 'chalk';
console.log(
chalkTemplate('<bold><red>Title</red></bold><error/>',
{
error: chalk.bold.red('Error!')
}
)
);
const log = console.log;
log(chalkTemplate`
CPU: {red ${cpu.totalPercent}%}
RAM: {green ${ram.used / ram.total * 100}%}
DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%}
`);
log(chalk.red.bgBlack(chalkTemplate`2 + 3 = {bold ${2 + 3}}`));
const miles = 18;
const calculateFeet = miles => miles * 5280;
console.log(chalk`
There are {bold 5280 feet} in a mile.
In {bold ${miles} miles}, there are {green.bold ${calculateFeet(miles)} feet}.
`);
```
See [supported styles](https://github.com/chalk/chalk#styles).
## API
Blocks are delimited by an opening curly brace (`{`), a style, some content, and a closing curly brace (`}`).
Template styles are chained exactly like normal [Chalk](https://github.com/chalk/chalk) styles. The following two statements are equivalent:
```js
import chalk from 'chalk';
import chalkTemplate from 'chalk-template';
console.log(chalk.bold.rgb(10, 100, 200)('Hello!'));
console.log(chalkTemplate`{bold.rgb(10,100,200) Hello!}`);
```
Note that function styles (`rgb()`, `hex()`, etc.) may not contain spaces between parameters.
All interpolated values (`` chalkTemplate`${foo}` ``) are converted to strings via the `.toString()` method. All curly braces (`{` and `}`) in interpolated value strings are escaped.
## Related
- [chalk](https://github.com/chalk/chalk) - API for this module
- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right
- [chalk-cli](https://github.com/chalk/chalk-cli) - Style text from the terminal
## Maintainers
## License
MIT © [Simon Mollweide](https://github.com/smollweide)
- [Sindre Sorhus](https://github.com/sindresorhus)
- [Josh Junon](https://github.com/qix-)

Sorry, the diff of this file is not supported yet

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