Skip to content

Commit

Permalink
feat(create_attribute): support object (#7)
Browse files Browse the repository at this point in the history
* feat(create_attribute): support object

* Avoid short form of if

Co-authored-by: Lee Rowlands <lee.rowlands@previousnext.com.au>
  • Loading branch information
tbourrelovh and larowlan authored Jul 1, 2021
1 parent a9afe22 commit a450a0c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ const loadTemplate = async (file, context = {}, namespaces) => {
}

Twig.cache(false)
Twig.extendFunction("create_attribute", (value) => new DrupalAttribute(value))
Twig.extendFunction("create_attribute", (value) => {
if (typeof value === 'object' && value !== null) {
value = Object.entries(value)
}
return new DrupalAttribute(value);
})
Twig.twigAsync = (options) => {
return new Promise((resolve, reject) => {
options.load = resolve
Expand Down

0 comments on commit a450a0c

Please sign in to comment.