elderjs icon indicating copy to clipboard operation
elderjs copied to clipboard

Shortcodes: openPattern '{{' doesn't work on linux (Arch linux), best alternative ? Possible fix ?

Open kinooyume opened this issue 4 years ago • 6 comments

openPattern: {{ doesn't work on my machine, I get this error message from rollup:

44:   {{ picture src={data.url} /}}
                 ^
...
ParseError: Unexpected token

(arrow under the 's' of src).

So for now I go with %% as the openPattern operator. All operator including bracket seems to have the same result, no problem with closePattern set to }}. Two questions about it:

  • What is the best alternative according to you ?
  • Do you think is something that can be fix in the future ? Thank's :)

kinooyume avatar Jan 20 '21 10:01 kinooyume

Have you tried without the space? {{picture src={data.url} /}}

Also, the first place I'd look is actually at the shortcode library (https://github.com/Elderjs/shortcodes) and see if those tests pass and possibly write a failing test if they do.

To use {{{ for instance you'd need to use regex escaped chars. I believe this would be:\\{\\{\\{ in your elder.config.js.

nickreese avatar Jan 20 '21 18:01 nickreese

Same result without the space and regex escaped as you described doesn't work either. I'll dig into this later.

kinooyume avatar Jan 21 '21 11:01 kinooyume

Same problem for me. I found a workaround that works:

tempalte.Svelte ... @@picture src={data.myLogoUrl} /@@@ ...

elder.confis.js ... openPattern: '@@', closePattern: '@@@', ...

ramshorst avatar Feb 12 '21 10:02 ramshorst

Also, you can use the helpers like this:

{@html helpers.shortcode( {name: 'shortcode_name',  props: {} } ) }

kinooyume avatar Mar 10 '21 16:03 kinooyume

Interesting, I might try that. Thanks !

ramshorst avatar Mar 10 '21 16:03 ramshorst

That's currently interesting, because if I understand well, this helper return the shortcode.

So: openPattern + your shortcode + closePattern

And it works even if we have {{ as openPattern.. Hum.. :thinking:

Edit: in elderjs/shortcodes, there is already a test about that and it pass on my machine.

Given these informations, the issue probably come from the implementation.

Investigate mode activate :eyes:

kinooyume avatar Mar 10 '21 16:03 kinooyume