Gathering detailed insights and metrics for tagged-templates-io
Gathering detailed insights and metrics for tagged-templates-io
npm install tagged-templates-io
Typescript
Module System
Node Version
NPM Version
70.2
Supply Chain
98.8
Quality
75.8
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
5,347
Last Day
1
Last Week
12
Last Month
49
Last Year
1,913
1 Stars
14 Commits
1 Forks
2 Watching
1 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
1.0.9
Package Id
tagged-templates-io@1.0.9
Unpacked Size
11.93 kB
Size
3.54 kB
File Count
4
NPM Version
8.18.0
Node Version
16.13.1
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
-25%
12
Compared to previous week
Last month
-54.2%
49
Compared to previous month
Last year
168.3%
1,913
Compared to previous year
No dependencies detected.
In most projects we use interpolations for several reasons. This could be simple html class-names, sql queries, or even more complicated strings that needs to be mutated on the fly. This is what this package is good for. You can easily create your own dynamic strings, with conditions, expressions or whatever you need.
1taggedTemplate(pattern, values, conditions); // string
Pattern | Values | Conditions | Result |
---|---|---|---|
string | number, string, [number or string] | boolean, string, number, null, [boolean, string, number, null] | string |
text {0} | 'val 1' | null | 'text val 1' |
text {0} and {0} | 'val 1' | null | 'text val 1 and val 1' |
text {0} and {1} | 'val 1' | null | 'text val 1 and val 1' |
text {0} and {1} | ['val 1', 'val 2'] | null | 'text val 1 and val 2' |
text {0} and {1} | [ ['val 1.0', 'val 1.1'], ['val 2.0', 'val 2.1'] ] | [ true, false ] | 'text val 1.0 and val 2.1' |
text {0} and {1} | [ ['val 1.0', 'val 1.1'], ['val 2.0', 'val 2.1'] ] | [ true, null ] | 'text val 1.0 and val 2.0' |
text {key1} and {key2} | { key1: ['val 1.1', 'val 1.2'], key2: ['val 2.1', 'val 2.2'] } | null | 'text val 1.1,val 1.2 and val 2.1,val 2.2' |
text {key1} and {key2} | { key1: ['val 1.1', 'val 1.2'], key2: ['val 2.1', 'val 2.2'] } | { key1: true, key2: false } | 'text val 1.1 and val 2.2' |
text {key1} and {key2} | { key1: ['val 1.1', 'val 1.2'], key2: ['val 2.1', 'val 2.2'] } | { key1: 'true', key2: null } | 'text val 1.1 and val 2.2' |
(key) => `text ${key}` | 'val 1' | null | 'text val 1' |
(key) => `text ${key}` | ['val 1'] | null | 'text val 1' |
(key) => `text ${key}` | ['val 1'] | true | 'text val 1' |
(key) => `text ${key}` | ['val 1'] | [true] | 'text val 1' |
(key) => `text ${key}` | ['val 1'] | [false] or false | 'text val 1' |
(key1, key2) => `text ${key1} and ${key2}` | [['val 1.1','val 1.2'],['val 2.1', 'val 2.2']] | [true, false] | 'text val 1.1 and val 2.2' |
1const isFirstNavItem = index === 0; 2 3const className = taggedTemplate( 4 `link__{1}--{0} link__type--{1}`, 5 [['active',''], 'nav'], 6 [isFirstNavItem, true] 7); 8 9<h1 :class="className">Title</h1> // VueJs Sample 10 11// Output 12 13// <h1 class="link__nav--active link__type--nav">Title</h1> 14
1const isClient = true; 2const as = 'age'; 3const from = ['clientTable', 'relationTable']; 4const fromCondition = isClient; 5const where = `${as} = ${42}`; 6const start = 0, end = 10; 7 8const a = taggedTemplate(` 9 SELECT {select} AS {as} 10 FROM {from} 11 WHERE {where} 12 LIMIT {start}, {end} 13`, 14 { select: 'age_col', as, from, where, start, end }, 15 { from: fromCondition }, 16) 17
1 2const classHandler = (id, activeIndex, classes) => { 3 if (!!classes) { 4 return taggedTemplate( 5 `class="{0}"`, 6 [[Array.from(new Set(classes)).join(' '), classes[0]]], 7 [id === activeIndex] 8 ); 9 } 10}; 11 12const activeIndex = 1; 13 14const result = taggedTemplate( 15 (listWrapper, listItems, activeClass, activeIndex) => ` 16 <ul class="${listWrapper}"> 17 ${listItems.reduce((ul, {id, label}) => { 18 return ul+`<li id="${id}" ${classHandler(id, activeIndex, activeClass)}>${label}</li>`; 19 }, '')} 20 </ul> 21 `, 22 [ 23 'list__wrapper', 24 [ 25 { id: 1, label: 'Item 1' }, 26 { id: 2, label: 'Item 2' } 27 ], 28 ['list__item','list__item--active'], 29 activeIndex 30 ] 31); 32 33/** 34 * Outputs 35 36<ul class="list__wrapper"> 37 <li id="1" class="list__item list__item--active"> 38 Item 1</li> 39 <li id="2" class="list__item"> 40 Item 2</li> 41</ul> 42 43*/
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/14 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More