Spark has been replaced by the Datastar plugin and is no longer available.
Spark started out as a Craft plugin that built on top of the Datastar framework. As Ben became more involved in the project, to the point of becoming a core contributor, he developed an official PHP SDK that does much of the work that Spark did.
Since the Craft plugin became a very thin layer, we figured we might as well call it what it is. The Datastar plugin is that thin layer, which stays as true to the framework’s API and ethos as possible.
Migrating to Datastar #
First uninstall Spark and install the Datastar plugin.
Spark used Datastar version 0.19.9, so you’ll need to convert all signals, data attributes and actions to the version v1.0.0‑beta.1 syntax (see the release notes).
Regular Templates #
- Action plugins now have a
@prefix. Replace all instances of$actionName()with@actionName(). - Replace
data-storewithdata-signals. - Replace
data-bindwithdata-attr. - Replace
data-modelwithdata-bind. - Replace
data-*attribute modifier delimiters.with__and argument delimiters_with.(data-on-keydown__debounce.100ms). - Replace
{{ spark(template, variables, method) }}tags with{{ datastar.get(template, variables, options) }}and{{ datastar.post(template, variables, options) }}tags. - Remove
{{ sparkUrl() }}tags and use{{ datastar.get(}) }}and{{ datastar.post(}) }}tags instead (no replacement exists). - Replace
{{ sparkStore() }}tags with{{ datastar.signals() }}. - Replace
{{ sparkStoreFromClass() }}tags with{{ datastar.signalsFromClass() }}.
Spark Templates #
- Ensure all fragments are wrapped in
{% fragment %}tags. - Replace the
storevariable withsignals. - Replace
spark.runActionwithdatastar.runAction. - Replace
{% do spark.remove(selector) %}tags with{% fragment remove selector %}tags. - Replace
{% do spark.redirect() %}tags with{% location %}tags. - Remove
{% do spark.console() %}tags and use{% executescript %}tags to output console messages using JavaScript.
Have a suggestion to improve the docs? Create an issue with details, and we'll do our best to integrate your ideas.