This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def truncate = { attrs, body -> | |
if (body().length() > attrs.maxlength.toInteger()) { | |
out << """<abbr title="${body()}">${body()[0..attrs.maxlength.toInteger() - 1]}...</abbr>""" | |
} else { | |
out << body() | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const x = { y: 1 }; | |
// Delete a key that doesn't exist from an optional chain | |
delete x?.y?.z; | |
// This results in: | |
// > {"y":1} | |
console.log(JSON.stringify(x)); |