Props in shortcode are passed as an Array instead of Object
NoelOConnell opened this issue · comments
When trying to create a shortcode for our site I noticed an issue with the props argument received in the shortcode run function.
I cloned and ran the Elderjs template project to make sure our configuration was not causing the issue.
Steps to reproduce
- Clone the Elderjs template
- Edit the
getting-started.md
and add thebox
shortcode that is shown in the documentation page.
{{box type="gray"}}
Your content here
{{/box}}
Expected output of props in the shortcode function
{ type: "gray" }
Actual
[ type: 'gray' ]
Hi, thanks for this. So I can try and recreate, can you let me know your output of npx envinfo --system --npmPackages svelte,rollup,webpack --binaries
? Thanks
Sure, here's the output
System:
OS: Windows 10 10.0.19042
CPU: (12) x64 AMD Ryzen 5 5600X 6-Core Processor
Memory: 20.58 GB / 31.92 GB
Binaries:
Node: 14.15.4 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.14.10 - C:\Program Files\nodejs\npm.CMD
npmPackages:
rollup: ^2.41.1 => 2.47.0
svelte: ^3.38.3 => 3.38.3
I also tried it running wsl2 on Windows and had the same issue.
Here's the output of that.
System:
OS: Linux 5.4 Ubuntu 20.04.3 LTS (Focal Fossa)
CPU: (12) x64 AMD Ryzen 5 5600X 6-Core Processor
Memory: 23.88 GB / 24.99 GB
Container: Yes
Shell: 5.0.17 - /bin/bash
Binaries:
Node: 14.17.6 - /usr/local/bin/node
Yarn: 1.22.5 - /mnt/c/Program Files (x86)/Yarn/bin/yarn
npm: 6.14.15 - /usr/local/bin/npm
npmPackages:
rollup: ^2.41.1 => 2.47.0
svelte: ^3.38.3 => 3.38.3
Turns out this was a legacy issue with the forked https://github.com/elderjs/shortcodes. I've updated it to always return an object. It is part of the latest release of Elder.js.