1
0
mirror of synced 2025-12-25 02:17:36 -05:00

rename helper module

This commit is contained in:
Sarah Schneider
2021-06-15 15:03:17 -04:00
parent 8d3375d75c
commit bf23c05cb5
2 changed files with 11 additions and 17 deletions

View File

@@ -1,17 +0,0 @@
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
}

View File

@@ -0,0 +1,11 @@
const { Tokenizer } = require('liquidjs')
module.exports = function getLiquidConditionals (str, tagNames) {
const tokenizer = new Tokenizer(str)
tagNames = Array.isArray(tagNames) ? tagNames : [tagNames]
return tokenizer.readTopLevelTokens()
.filter(token => tagNames.includes(token.name))
.map(token => token.args)
}