MCPcopy Index your code
hub / github.com/github/docs / getLiquidConditionals

Function getLiquidConditionals

script/helpers/get-liquid-conditionals.js:12–20  ·  view source on GitHub ↗
(str, tagNames)

Source from the content-addressed store, hash-verified

10
11// Return an array of just the conditional strings.
12function 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.

Callers 2

getConditionalsToUpdateFunction · 0.90
lint-versioning.jsFile · 0.90

Calls 1

tokenizeFunction · 0.70

Tested by

no test coverage detected