1
0
mirror of synced 2025-12-22 03:16:52 -05:00
Files
docs/lib/get-liquid-data-references.js
Jason Etcovitch caaee7a124 Update all files to use {% data %} (#15253)
* Add back changes from prior to purge

* Manually fix some invalid Liquid

* Updoot render-content

* Improve test messages to show correct output

* Run el scripto

* Pass the remaining test
2020-09-29 16:01:04 -04:00

16 lines
483 B
JavaScript

// This module searches a string for references to data objects
// It finds all references matching {{site.data.*}} and return an array of them
const patterns = require('./patterns')
module.exports = function getLiquidDataReferences (text) {
return (text.match(patterns.dataReference) || [])
.map(ref => {
const cleaned = ref.replace(/\.\.\//g, '')
.replace('{% data', '')
.replace('%}', '')
.trim()
return `site.data.${cleaned}`
})
}