Skip to content

Commit 6b51cec

Browse files
authored
Fix renderContent.liquid (#38571)
1 parent 071a3f8 commit 6b51cec

File tree

3 files changed

+10
-19
lines changed

3 files changed

+10
-19
lines changed

src/content-linter/lib/linting-rules/image-alt-text-length.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { addError, forEachInlineChild } from 'markdownlint-rule-helpers'
2-
import { renderContent } from '#src/content-render/index.js'
2+
import { liquid } from '#src/content-render/index.js'
33

44
export const incorrectAltTextLength = {
55
names: ['MD111', 'incorrect-alt-text-length'],
@@ -11,7 +11,7 @@ export const incorrectAltTextLength = {
1111
let renderedString = token.content
1212
if (token.content.includes('{%') || token.content.includes('{{')) {
1313
const context = { currentLanguage: 'en' }
14-
renderedString = await renderContent.liquid.parseAndRender(token.content, context)
14+
renderedString = await liquid.parseAndRender(token.content, context)
1515
}
1616

1717
if (renderedString.length < 40 || renderedString.length > 150) {

src/content-linter/tests/lint-files.js

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import languages from '../../../lib/languages.js'
1919
import { tags } from '#src/content-render/liquid/extended-markdown.js'
2020
import releaseNotesSchema from '../lib/release-notes-schema.js'
2121
import learningTracksSchema from '../lib/learning-tracks-schema.js'
22-
import { renderContent } from '#src/content-render/index.js'
22+
import { renderContent, liquid } from '#src/content-render/index.js'
2323
import getApplicableVersions from '../../../lib/get-applicable-versions.js'
2424
import { allVersions } from '../../../lib/all-versions.js'
2525
import { getDiffFiles } from '../lib/diff-files.js'
@@ -467,7 +467,7 @@ describe('lint markdown content', () => {
467467
await Promise.all(
468468
yamlScheduledWorkflows.map(async (snippet) => {
469469
// If we don't parse the Liquid first, yaml loading chokes on {% raw %} tags
470-
const rendered = await renderContent.liquid.parseAndRender(snippet, context)
470+
const rendered = await liquid.parseAndRender(snippet, context)
471471
const parsed = yaml.load(rendered)
472472
return parsed.on.schedule
473473
})
@@ -669,7 +669,7 @@ describe('lint markdown content', () => {
669669
// If Liquid can't parse the file, it'll throw an error.
670670
// For example, the following is invalid and will fail this test:
671671
// {% if currentVersion ! "github-ae@latest" %}
672-
expect(() => renderContent.liquid.parse(content)).not.toThrow()
672+
expect(() => liquid.parse(content)).not.toThrow()
673673
})
674674

675675
if (!markdownRelPath.includes('data/reusables')) {
@@ -679,7 +679,7 @@ describe('lint markdown content', () => {
679679
)
680680

681681
for (const key of fmKeysWithLiquid) {
682-
expect(() => renderContent.liquid.parse(frontmatterData[key])).not.toThrow()
682+
expect(() => liquid.parse(frontmatterData[key])).not.toThrow()
683683
}
684684
})
685685
}
@@ -963,10 +963,7 @@ describe('lint GHES release notes', () => {
963963

964964
for (const key in toLint) {
965965
if (!toLint[key]) continue
966-
expect(
967-
() => renderContent.liquid.parse(toLint[key]),
968-
`${key} contains invalid liquid`
969-
).not.toThrow()
966+
expect(() => liquid.parse(toLint[key]), `${key} contains invalid liquid`).not.toThrow()
970967
}
971968
})
972969
})
@@ -1030,10 +1027,7 @@ describe('lint GHAE release notes', () => {
10301027

10311028
for (const key in toLint) {
10321029
if (!toLint[key]) continue
1033-
expect(
1034-
() => renderContent.liquid.parse(toLint[key]),
1035-
`${key} contains invalid liquid`
1036-
).not.toThrow()
1030+
expect(() => liquid.parse(toLint[key]), `${key} contains invalid liquid`).not.toThrow()
10371031
}
10381032
})
10391033
})
@@ -1117,10 +1111,7 @@ describe('lint learning tracks', () => {
11171111
})
11181112

11191113
toLint.forEach((element) => {
1120-
expect(
1121-
() => renderContent.liquid.parse(element),
1122-
`${element} contains invalid liquid`
1123-
).not.toThrow()
1114+
expect(() => liquid.parse(element), `${element} contains invalid liquid`).not.toThrow()
11241115
})
11251116
})
11261117
})

src/content-render/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ The class and the template should have corresponding names, like `lib/liquid-tag
9090
You must also register the new tag in `src/content-render/liquid/engine.js` with a line like this:
9191

9292
```
93-
renderContent.liquid.registerTag('my_tag', require('./liquid-tags/my-tag'))
93+
engine.registerTag('my_tag', require('./liquid-tags/my-tag'))
9494
```
9595

9696
## Further reading

0 commit comments

Comments
 (0)