1
0
mirror of synced 2026-01-23 12:02:29 -05:00
Files
docs/tests/helpers/get-ifversion-conditionals.js
2021-06-11 15:23:09 -04:00

18 lines
505 B
JavaScript

const renderContent = require('../../lib/render-content')
module.exports = function getIfversionConditionals (str) {
const conditionals = []
renderContent.liquid.parse(str)
.filter(block => block.name === 'ifversion')
// block.impl.branches is the only way to get an array of ifs and elsifs.
.map(block => block.impl.branches.map(branch => branch.cond))
.forEach(block => {
block.forEach(branch => {
conditionals.push(branch)
})
})
return conditionals
}