Comparing version 2.10.0 to 2.11.0
{ | ||
"name": "btrz-pdf", | ||
"version": "2.10.0", | ||
"version": "2.11.0", | ||
"description": "Generates pdf documents based on a liquid template", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -162,6 +162,8 @@ const {timezones, BzDate} = require("bz-date"); | ||
render: async function(ctx) { | ||
if (ctx && ctx.environments && ctx.environments.providerPreferences && ctx.environments.providerPreferences.preferences && | ||
ctx.environments[this.item] && ctx.environments[this.item][this.propName]) { | ||
if (ctx && ctx.environments && ctx.environments.providerPreferences && ctx.environments.providerPreferences.preferences) { | ||
const format = ctx.environments.providerPreferences.preferences.dateFormat; | ||
return getDate(ctx.environments, this.item, this.propName, format, this.applyTimeZone); | ||
const item = await getNameOrValue(this.item, this.propName, ctx, this.liquid); | ||
if (item) { | ||
return getDate(ctx.environments, item, this.propName, format, this.applyTimeZone); | ||
} | ||
} | ||
@@ -168,0 +170,0 @@ return "PNA"; |
@@ -58,3 +58,7 @@ describe("index.js", () => { | ||
} | ||
] | ||
], | ||
updatedAt: { | ||
value: "2021-12-20T16:08:00.488Z", | ||
offset: 0 | ||
} | ||
}, | ||
@@ -611,6 +615,2 @@ providerPreferences: { | ||
]; | ||
data.transaction.updatedAt = { | ||
value: "2021-12-20T16:08:00.488Z", | ||
offset: 0 | ||
}; | ||
const pdf = require("../src/index"); | ||
@@ -643,2 +643,35 @@ const template = `{ | ||
it("should format dateF outside and inside a for loop", async () => { | ||
data.things = [ | ||
{ | ||
data: {createdAt: {value: "2021-12-21T16:38:22.488Z", offset: 0}} | ||
}, | ||
{ | ||
data: {createdAt: {value: "2021-12-22T16:32:22.488Z", offset: 0}} | ||
} | ||
]; | ||
const pdf = require("../src/index"); | ||
const template = `{ | ||
"content": [ | ||
{%- for thing in things -%} | ||
"{%- dateF thing.data createdAt %}", | ||
"{%- dateF thing.data wrongProp %}", | ||
{%- endfor -%} | ||
"{%- dateF transaction updatedAt %}", | ||
"{%- dateF transaction wrongProp %}" | ||
] | ||
}`; | ||
const documentDefinition = await pdf.toDocumentDefinition(template, data); | ||
expect(documentDefinition).to.be.eql({ | ||
"content": [ | ||
"12/21/2021", | ||
"PNA", | ||
"12/22/2021", | ||
"PNA", | ||
"12/20/2021", | ||
"PNA", | ||
] | ||
}); | ||
}); | ||
it("should return a pdf document", (done) => { | ||
@@ -645,0 +678,0 @@ const pdf = require("../src/index.js"); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
420400
10168