
Security News
CISA Extends MITRE Contract as Crisis Accelerates Alternative CVE Coordination Efforts
CISA extended MITRE’s CVE contract by 11 months, avoiding a shutdown but leaving long-term governance and coordination issues unresolved.
Lightweight templating in 154 bytes
Allows you to denote dynamic portions of a string using double curly brackets ({{ example }}
) & then replace them with matching values from your data source.
You may attach an Object
or an Array
as your data source, which means you may use the object's keys or the array's indices to assign values.
Lastly, you may use dot-notated paths to access (deeply) nested values; eg: foo.bar.baz
, 0.0.0
, or foo.0.1.bar
.
$ npm install --save templite
const templite = require('templite');
templite('Hello, {{name}}!', { name: 'world' });
//=> Hello, world!
templite('Howdy, {{0}}! {{1}}', ['partner', '🤠']);
//=> Howdy, partner! 🤠
templite('foo: "{{foo}}"; bar: "{{bar}}";', { foo: 123 });
//=> foo: "123"; bar: "";
templite(`
Name: {{name.last}}, {{name.first}}
Location: {{address.city}} ({{address.country}})
Hobbies: {{hobbies.0}}, {{hobbies.1}}, {{hobbies.2}}
`, {
name: {
first: 'Luke',
last: 'Edwards'
},
address: {
city: 'Los Angeles',
country: 'USA'
},
hobbies: ['eat', 'sleep', 'repeat']
});
//=> Name: Edwards, Luke
//=> Location: Los Angeles (USA)
//=> Hobbies: eat, sleep, repeat
Type: String
The string template to operate upon.
Its dynamic placeholders are signified with double curly brackets ({{foo}}
or {{ foo }}
) and may map to key names or indices. They may also reference deeply nested values via dot-notation (foo.bar.baz
).
Unknown keys/indices and null
or undefined
values are replaced with an empty string (''
).
Type: Array
or Object
The data source for your template injections.
MIT © Luke Edwards
FAQs
Lightweight templating in 154 bytes
The npm package templite receives a total of 21,398 weekly downloads. As such, templite popularity was classified as popular.
We found that templite demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA extended MITRE’s CVE contract by 11 months, avoiding a shutdown but leaving long-term governance and coordination issues unresolved.
Product
Socket's Rubygems ecosystem support is moving from beta to GA, featuring enhanced security scanning to detect supply chain threats beyond traditional CVEs in your Ruby dependencies.
Research
The Socket Research Team investigates a malicious npm package that appears to be an Advcash integration but triggers a reverse shell during payment success, targeting servers handling transactions.