New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

btrz-pdf

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

btrz-pdf - npm Package Compare versions

Comparing version 2.8.1 to 2.9.0

src/object.js

27

docs/index.md

@@ -788,2 +788,29 @@ ---

{% raw %} {%- httpImg brand.logos.default -%} {% endraw %} // data:image/png;base64,77+9UE5HDQoaCgAAAA1JSERSAAA...
```
### Supported filters
* ## keys
Given an Object converts it to an array of keys.
For this object:
```json
{
"prop1": "value1",
"prop2": "value2"
}
```
You can iterate over the object keys
```liquid
{% raw %}
{%- assign objectKeys = brand.logos.default -%}
{%- for aKey in objectKeys -%}
Key number {%forloop.index%} : {{aKey}}
{%- endfor -%}
{% endraw %}
//"Key number 1: prop1"
//"Key number 2: prop2"
```

2

package.json
{
"name": "btrz-pdf",
"version": "2.8.1",
"version": "2.9.0",
"description": "Generates pdf documents based on a liquid template",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -16,2 +16,3 @@ const {Liquid} = require("liquidjs");

const {HttpImg} = require("./httpimg.js");
const {Keys} = require("./object.js");
const pdfjs = require("pdfjs");

@@ -118,4 +119,4 @@

engine.plugin(HttpImg);
engine.plugin(Keys);
const str = await engine.parseAndRender(liquidTemplate, data);
try {

@@ -122,0 +123,0 @@ const obj = JSON.parse(str);

@@ -655,2 +655,32 @@ describe("index.js", () => {

});
it("should allow to loop over an object keys", async () => {
const pdf = require("../src/index");
const template = `{
"content": [
{% assign objectKeys = ticket.displayCurrency | keys %}
{% for aKey in objectKeys %}
{% if forloop.first %}
{
{% endif %}
{% unless forloop.last %}
"key{{forloop.index}}": "{{aKey}}",
{% else %}
"key{{forloop.index}}": "{{aKey}}"}
{% endunless %}
{% endfor %}
]
}`
const documentDefinition = await pdf.toDocumentDefinition(template, data);
expect(documentDefinition).to.be.eql({
"content": [
{
"key1": "isocode",
"key2": "symbol",
"key3": "buy",
"key4": "sell",
}
]
});
});
});
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