(str, tagNames)
| 10 | |
| 11 | // Return an array of just the conditional strings. |
| 12 | function getLiquidConditionals(str, tagNames) { |
| 13 | if (!tagNames) throw new Error(`Must provide a tag name!`) |
| 14 | if (typeof str !== 'string') throw new Error('Must provide a string!') |
| 15 | tagNames = Array.isArray(tagNames) ? tagNames : [tagNames] |
| 16 | |
| 17 | return tokenize(str) |
| 18 | .filter((token) => tagNames.includes(token.name)) |
| 19 | .map((token) => token.args) |
| 20 | } |
| 21 | |
| 22 | // Return an array of objects, where the `conditional` prop contains the conditional string, |
| 23 | // and the `text` prop contains the contents between the start tag and the end tag. |
no test coverage detected