Skip to content

Commit 2289ca7

Browse files
authored
Merge pull request github#5606 from github/repo-sync
repo sync
2 parents 54932df + 8a92a3b commit 2289ca7

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

lib/liquid-tags/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Note that link tags will only render links that are available in the current pag
6363
| `{% homepage_link_with_intro /href %}` | The linked page's title and intro, with homepage-specific styling.
6464
| `{% link_in_list /href %}` | The linked page's title in a list item.
6565
| `{% topic_link_in_list /href %}` | The linked map topic's title in a list item (used in category TOCs).
66-
| `{% indented_data_reference site.data.foo.bar spaces=NUMBER %}` | The data reference with the specified number of spaces prepended to each line.
66+
| `{% indented_data_reference foo.bar spaces=NUMBER %}` | A data reference with the specified number of spaces prepended to each line. Defaults to 2 spaces if no spaces included. For example: `{% indented_data_reference reusables.enterprise_management_console.enable-disable-security-features %}`
6767

6868
## Creating tags
6969

lib/liquid-tags/indented-data-reference.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ module.exports = {
3030
assert(parseInt(numSpaces) || numSpaces === '0', '"spaces=NUMBER" must include a number')
3131

3232
// Get the referenced value from the context
33-
const value = await this.liquid.evalValue(dataReference, context)
33+
const value = await this.liquid.evalValue(`site.data.${dataReference}`, context)
3434

3535
// If nothing is found in the context, exit with nothing; this may
3636
// feel weird and that we should throw an error, but this is "The Liquid Way TM"

tests/unit/liquid-helpers.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,31 +107,31 @@ describe('liquid helper tags', () => {
107107

108108
describe('indented_data_reference tag', () => {
109109
test('without any number of spaces specified', async () => {
110-
const template = '{% indented_data_reference site.data.reusables.example %}'
110+
const template = '{% indented_data_reference reusables.example %}'
111111
const expected = ` a rose by any other name
112112
would smell as sweet`
113113
const output = await liquid.parseAndRender(template, context)
114114
expect(output).toBe(expected)
115115
})
116116

117117
test('with 0 spaces specified', async () => {
118-
const template = '{% indented_data_reference site.data.reusables.example spaces=0 %}'
118+
const template = '{% indented_data_reference reusables.example spaces=0 %}'
119119
const expected = `a rose by any other name
120120
would smell as sweet`
121121
const output = await liquid.parseAndRender(template, context)
122122
expect(output).toBe(expected)
123123
})
124124

125125
test('with 0 spaces specified and whitespace around equals sign', async () => {
126-
const template = '{% indented_data_reference site.data.reusables.example spaces = 0 %}'
126+
const template = '{% indented_data_reference reusables.example spaces = 0 %}'
127127
const expected = `a rose by any other name
128128
would smell as sweet`
129129
const output = await liquid.parseAndRender(template, context)
130130
expect(output).toBe(expected)
131131
})
132132

133133
test('with 5 spaces specified', async () => {
134-
const template = '{% indented_data_reference site.data.reusables.example spaces=5 %}'
134+
const template = '{% indented_data_reference reusables.example spaces=5 %}'
135135
const expected = ` a rose by any other name
136136
would smell as sweet`
137137
const output = await liquid.parseAndRender(template, context)

0 commit comments

Comments
 (0)