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

Shortcodes don’t parse variables #1089

Closed
paulrobertlloyd opened this issue Apr 11, 2020 · 4 comments
Closed

Shortcodes don’t parse variables #1089

paulrobertlloyd opened this issue Apr 11, 2020 · 4 comments

Comments

@paulrobertlloyd
Copy link
Contributor

paulrobertlloyd commented Apr 11, 2020

Describe the bug
Short codes only appear to accept strings for arguments. Passing a variable returns undefined.

To Reproduce
Steps to reproduce the behavior:

  1. Register a new universal (or Liquid, same result) shortcode:

    eleventyConfig.addShortcode('test', arg => {
      console.log('argument', arg);
    });
  2. Use this shortcode with a string and a variable (Liquid template shown):

    {% test 'foobar' %}
    
    {% assign foobar = 'foobar' %}
    {% test foobar %}
    
  3. Build your site. The following is output:

    argument foobar
    argument undefined

Expected behaviour
I expected to be able to pass variables to a shortcode, and for these to be parsed as strings.

Environment:

  • OS and Version: macOS 10.15.4
  • Eleventy Version: 0.11.0-beta.3

Additional context
Not sure if this is a regression in 0.11.beta-3, or if this has always been the case, as have only started experimenting with shortcodes.

@paulrobertlloyd
Copy link
Contributor Author

@zachleat My apologies. I had a very insightful thought in the shower this morning; the bugs I’m finding in 11ty all relate to Liquid, and I’m using my own LiquidJS instance (v9.x). Sure enough, downgrading Liquid to use the built in version means the above issue no longer presents itself.

Linking this to PR #1058 as something to check when this upgrade is merged in.

@stefanfrede
Copy link

I ran into exactly the same problem today, I'm unable to pass down variables as arguments to my shortcodes. They all resolve to undefined.

I too use my own LiquidJs instance.

Is there something I can do to solve this?

@binyamin binyamin added bug and removed needs-triage labels Nov 2, 2020
@andrewek
Copy link

I ran into this issue with 11ty 0.12.1 (also 1.0.0) and the default Liquid install.

In my yarn.lock I notice that liquidjs 9.28.0 and 6.4.3 are both installed, which is somewhat puzzling. It looks like 6.4.3 is the dependency set by 11ty 0.12.1., whereas 9.28.0 is relied upon by other dependencies.

Will dig more into it as I have time. At this time it is not a show-stopper.

@zachleat
Copy link
Member

zachleat commented Dec 6, 2022

I tested this as fixed on both 1.0 and 2.0!

I’m guessing this was a duplicate of #2367 in retrospect (shipped with 1.0.2 and 2.0.0-canary.9)

Thanks!

@zachleat zachleat closed this as completed Dec 6, 2022
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

5 participants