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

@itrocks/template

Package Overview
Dependencies
Maintainers
0
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@itrocks/template - npm Package Compare versions

Comparing version 0.0.11 to 0.0.12

2

package.json

@@ -60,3 +60,3 @@ {

"types": "./esm/template.d.ts",
"version": "0.0.11"
"version": "0.0.12"
}

@@ -20,9 +20,10 @@ [![view on npm](https://badgen.net/npm/v/@itrocks/template)](https://www.npmjs.org/package/@itrocks/template)

```ts
console.log(
await new Template({
users: [
{ age: 10, name: 'kid' },
{ age: 20, name: 'old-timer' }
]
})
import '@itrocks/template'
new Template({
users: [
{ age: 10, name: 'kid' },
{ age: 20, name: 'old-timer' }
]
})
.parseBuffer(`

@@ -35,3 +36,3 @@ <ul>

`)
)
.then(console.log)
```

@@ -71,3 +72,4 @@

parsing returns a [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)
that you should handle with [await](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/await).
that you should handle with [await](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/await)
or [then](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise/then).

@@ -201,5 +203,3 @@ This library is fully compatible with both ECMAScript modules (import) and CommonJS (require),

```ts
console.log(
await new Template({ var: 15 }).parseBuffer('<span>{var}</span>')
)
new Template({ var: 15 }).parseBuffer('<span>{var}</span>').then(console.log)
```

@@ -215,5 +215,3 @@ Result:

```ts
console.log(
await new Template({ var: () => 15 }).parseBuffer('<span>{var}</span>')
)
new Template({ var: () => 15 }).parseBuffer('<span>{var}</span>').then(console.log)
```

@@ -229,3 +227,3 @@ Result:

```ts
console.log(await new Template(15).parseBuffer('<span>{.}</span>'))
new Template(15).parseBuffer('<span>{.}</span>').then(console.log)
```

@@ -273,13 +271,11 @@ Result:

```ts
console.log(
await new Template({ user: { age: 10, name: 'kid' } })
.parseBuffer('<span>{user.name} is {user.age} years old</span>')
)
new Template({ user: { age: 10, name: 'kid' } })
.parseBuffer('<span>{user.name} is {user.age} years old</span>')
.then(console.log)
```
Or use a block to avoid repeating:
```ts
console.log(
await new Template({ user: { age: 10, name: 'kid' } })
.parseBuffer('<span><!--user-->{name} is {age} years old<!--end--></span>')
)
new Template({ user: { age: 10, name: 'kid' } })
.parseBuffer('<span><!--user-->{name} is {age} years old<!--end--></span>')
.then(console.log)
```

@@ -295,6 +291,5 @@ Both produce:

```ts
console.log(
await new Template({ object: { first: 'kid', next: 'old-timer' } })
.parseBuffer('<ul><!--object.*--><li>{.}<!--end--></ul>')
)
new Template({ object: { first: 'kid', next: 'old-timer' } })
.parseBuffer('<ul><!--object.*--><li>{.}<!--end--></ul>')
.then(console.log)
```

@@ -309,6 +304,5 @@ Result:

```ts
console.log(
await new Template({ users: ['kid', 'old-timer'] })
.parseBuffer('<ul><!--users--><li>{.}</li><!--end--></ul>')
)
new Template({ users: ['kid', 'old-timer'] })
.parseBuffer('<ul><!--users--><li>{.}</li><!--end--></ul>')
.then(console.log)
```

@@ -323,9 +317,8 @@ Result:

```ts
console.log(
await new Template({
users: [
{ age: 10, name: 'kid' },
{ age: 20, name: 'old-timer' }
]
})
await new Template({
users: [
{ age: 10, name: 'kid' },
{ age: 20, name: 'old-timer' }
]
})
.parseBuffer(`

@@ -338,3 +331,3 @@ <ul>

`)
)
.then(console.log)
```

@@ -353,4 +346,3 @@ Result:

```ts
console.log(
await new Template({ name: 'Eddie', data: { age: 30, status: 'well' } })
new Template({ name: 'Eddie', data: { age: 30, status: 'well' } })
.parseBuffer(`

@@ -365,3 +357,3 @@ <!--data-->

`)
)
.then(console.log)
```

@@ -390,6 +382,5 @@ Result:

```ts
console.log(
await new Template({ name: 'EDITH' })
.parseBuffer('<span>{name.lcFirst}</span>')
)
new Template({ name: 'EDITH' })
.parseBuffer('<span>{name.lcFirst}</span>')
.then(console.log)
```

@@ -468,9 +459,8 @@ Result:

```ts
console.log(
await new MyTemplate({ name: 'Nick' })
.parseBuffer(`
<h2>What is my name</h2>
<p>My name is {name}</p>
`)
)
new MyTemplate({ name: 'Nick' })
.parseBuffer(`
<h2>What is my name</h2>
<p>My name is {name}</p>
`)
.then(console.log)
```

@@ -486,9 +476,8 @@ Results in:

```ts
console.log(
await new MyTemplate({ name: 'Nick' })
.parseBuffer(`
<h2>What is my name</h2>
<p>My <span>name</span> is {name}</p>
`)
)
new MyTemplate({ name: 'Nick' })
.parseBuffer(`
<h2>What is my name</h2>
<p>My <span>name</span> is {name}</p>
`)
.then(console.log)
```

@@ -611,3 +600,3 @@ Results in:

```ts
await new Template({ name: 'Nick' })
const parsed = await new Template({ name: 'Nick' })
.parseFile('child-template.html', 'container-template.html')

@@ -630,3 +619,3 @@ ```

template.debugEvents()
await template.parseBuffer(yourTemplateString)
const parsed = await template.parseBuffer(yourTemplateString)
```

@@ -633,0 +622,0 @@ As the template is parsed, the console will show events like:

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