rename helper module
This commit is contained in:
@@ -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
|
||||
}
|
||||
11
tests/helpers/get-liquid-conditionals.js
Normal file
11
tests/helpers/get-liquid-conditionals.js
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user