putyourlightson / craft-spark

A real-time, template-driven hypermedia framework for Craft CMS.
Other
11 stars 0 forks source link

Syntax broken in `0.0.7`? #7

Closed wbrowar closed 2 hours ago

wbrowar commented 3 hours ago

Bug Report

Hey @bencroker, I updated Spark to 0.0.7, updated my example code and tried to run it and got the following error in Chrome:

Screenshot 2024-10-20 at 2 31 30 PM

Here is the demo code I'm using. This is in my index.twig file:

{# Basic store and POST request test. #}
<div data-store="{ textInput: 'planet' }">
    <input type="text" placeholder="Type here!" data-model="textInput" data-on-blur="{{ spark('_spark/main.twig', {}, 'post') }}')" />

    <button id="main-button" data-on-click="{{ spark('_spark/main.twig', {}, 'post') }}')">
        Change it!
    </button>

    <div id="first">
        This is the first thing.
    </div>

    <div id="second">
        This is the second thing.
    </div>
</div>

And this is in my main.twig file:

{# templates/_spark/main.twig #}

<div id="first">
  Oh, hi, {{ store.textInput }}!
</div>

<div id="second">
  And uh, hello, {{ currentUser.friendlyName ?? 'nobody' }}?
</div>

To isolate this I commented out the rest of the things I was testing Spark for so this should be the only thing interacting with Spark.


Also, unrelated to my issue above, I noticed a few typos in the docs:

Plugin Version

0.0.7

Craft CMS Version

5.4.8

PHP Version

8.2.22

bencroker commented 3 hours ago

You have an extra trailing ').

data-on-blur="{{ spark('_spark/main.twig', {}, 'post') }}')"

It should read:

data-on-blur="{{ spark('_spark/main.twig', {}, 'post') }}"
bencroker commented 3 hours ago

None of those appear to be typos in the docs, but let me know if I’ve overlooked something. I did a lot of work on the docs today and some clean up will likely follow.

wbrowar commented 7 minutes ago

Ah, good eye on the extra '). I took them all out and it's all working correctly again!

Regarding the docs, I'm still seeing some of the things I mentioned above, so maybe it's a rendering issue with the doc blocks?

Screenshot 2024-10-20 at 6 27 28 PM