Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Liquid & separating shortcode params to separate lines #3332

Closed
ijlind opened this issue Jun 23, 2024 · 1 comment
Closed

Liquid & separating shortcode params to separate lines #3332

ijlind opened this issue Jun 23, 2024 · 1 comment

Comments

@ijlind
Copy link

ijlind commented Jun 23, 2024

Operating system

macOS Sonoma 14.5

Eleventy

2.0.1

Describe the bug

When using Liquid as the template engine, I am unable to split the shortcode arguments into multiple lines. For example, given a shortcode with the following signature:

eleventyConfig.addShortcode("image", function (src, alt, caption) { ... });

Everything works fine if I use this shortcode in a .liquid file like this:

{% image 'src' 'alt' 'caption' %}

But if I add line breaks and line breaks separators (for readability) like so:

{% image
  , 'src'
  , 'alt'
  , 'caption'
%}

I get an error from eleventy:

[11ty] 1. Having trouble rendering liquid template ./src/pages/index.liquid (via TemplateContentRenderError)
[11ty] 2. invalid syntax at line 1 col 8:
[11ty] 
[11ty] 1  , 'src'
[11ty]           ^
[11ty] 2        , 'alt'
[11ty] 3        , 'caption', file:./src/pages/index.liquid, line:17, col:5 (via RenderError)
[11ty] 3. invalid syntax at line 1 col 8:
[11ty] 
[11ty] 1  , 'src'
[11ty]           ^
[11ty] 2        , 'alt'
[11ty] 3        , 'caption' (via Error)
[11ty] 
[11ty] Original error stack trace: Error: invalid syntax at line 1 col 8:
[11ty] 
[11ty] 1  , 'src'
[11ty]           ^
[11ty] 2        , 'alt'
[11ty] 3        , 'caption'
[11ty]     at Lexer._token (.../node_modules/moo/moo.js:559:17)
[11ty]     at Lexer.next (.../node_modules/moo/moo.js:506:19)
[11ty]     at Liquid.parseArguments (...node_modules/@11ty/eleventy/src/Engines/Liquid.js:146:21)
[11ty]     at Tag.render (.../node_modules/@11ty/eleventy/src/Engines/Liquid.js:162:32)
[11ty]     at render.next (<anonymous>)
[11ty]     at toPromise (.../node_modules/liquidjs/dist/liquid.node.cjs.js:451:32)
[11ty]     at toPromise (.../node_modules/liquidjs/dist/liquid.node.cjs.js:457:25)
[11ty]     at async toPromise (.../node_modules/liquidjs/dist/liquid.node.cjs.js:459:25)
[11ty]     at async Template._render (.../node_modules/@11ty/eleventy/src/TemplateContent.js:514:22)
[11ty]     at async Template.renderWithoutLayout (.../node_modules/@11ty/eleventy/src/Template.js:456:27)

Is there a reason why this format should not be supported? AFAIK it is a standard liquid formatting style.

@zachleat
Copy link
Member

Almost certainly a duplicate of #2679

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants