Sprig
Version 2.6.2
May 1, 2023
Changed
- Updated htmx to version 1.9.2 (changelog).
- Improved autocomplete documentation in the playground.
Version 2.6.1
April 25, 2023
Fixed
- Fixed a bug in which the htmx file was not being published even if it did not already exist locally (#305).
Version 2.6.0
April 23, 2023
Added
- Added the sprig.setConfig template variable that allows you to set configuration options for htmx (via a meta tag).
- Added the s-on attribute that allows you to respond to events directly on an element.
Changed
- Updated htmx to version 1.9.0 (release notes).
- The htmx file is now loaded locally rather than from a CDN, to reduce dependency on third-party sites (#303).
Version 2.5.1
January 31, 2023
Fixed
- Fixed rendered markup not being escaped in the Sprig playground.
Version 2.5.0
January 18, 2023
Added
- Added the s-history attribute that prevents sensitive data being saved to the history cache.
Changed
- Updated htmx to version 1.8.5 (release notes).
Version 2.4.0
December 8, 2022
Added
- Added the sprig.triggerRefreshOnLoad template variable that triggers a refresh event on all components on page load (#279).
Version 2.3.0
November 7, 2022
Added
- Added the s-validate attribute that forces an element to validate itself before it submits a request.
- Added the sprig.isHistoryRestoreRequest template variable that returns whether the request is for history restoration after a miss in the local history cache a client-side redirect without reloading the page.
Changed
Version 2.2.1
October 8, 2022
Fixed
- Fixed a bug in which Sprig requests were failing in live preview requests (#269).
Version 2.2.0
October 5, 2022
Added
- Added the s-replace-url attribute that allows you to replace the current url of the browser location history.
- Added the s-select-oob attribute that selects one or more elements from a server response to swap in via an out-of-band swap.
- Added the sprig.location(url) template variable that triggers a client-side redirect without reloading the page.
- Added the sprig.replaceUrl(url) template variable that replaces the current URL in the location bar.
- Added the sprig.reswap(value) template variable that allows you to change the swap behaviour.
Changed
- Updated htmx to version 1.8.0 (release notes).
Version 2.1.0
June 22, 2022
Added
- Added the Twigfield package that adds full autocomplete to the code editor in the playground (#235 ❤️@nystudio107).
Changed
- Improved attribute autocomplete in the playground.
Version 2.0.1
May 12, 2022
Changed
- Improved the styling of variables panes in the playground.
Version 2.0.0
May 4, 2022
Added
- Added compatibility with Craft 4.
Changed
- Restyled invalid variable error messages.
Removed
- Removed the deprecated
sprig.element
,sprig.elementName
,sprig.elementValue
andsprig.eventTarget
tags. - Removed the deprecated
s-vars
attribute.
Version 1.12.4
April 14, 2022
Fixed
- Fixed the minimum PHP requirement format to allow for PHP 8 (#215).
Version 1.12.3
April 14, 2022
Changed
- Changed the minimum PHP requirement to 7.1.
Fixed
- Fixed an issue where the
Autocomplete
helper could throw an exception if it encountered aReflectionUnionType
(#213).
Version 1.12.2
March 24, 2022
Fixed
- Fixed nested components being parsed twice, resulting in duplicate attributes (#208).
Version 1.12.1
March 15, 2022
Fixed
- Fixed an issue that caused htmx 1.7.0 to log console errors in some edge cases (#202).
Version 1.12.0
March 1, 2022
Added
- Added the s-sync attribute that allows you to synchronize AJAX requests between multiple elements.
- Added the s-disinherit attribute that allows you to control attribute inheritance.
Changed
- Updated htmx to version 1.7.0 (release notes).
Version 1.11.1
February 22, 2022
Changed
- The response format is now explicitly set to HTML, to avoid a scenario in which it might be interpreted as JSON.
Version 1.11.0
February 1, 2022
Added
- Added a sprig.isBoosted template variable that returns whether this is a boosted request (requires htmx 1.6.0 or later).
- Added a sprig.retarget() template variable that overrides the element to target via a CSS selector (requires htmx 1.6.1 or later).
Changed
- Updated htmx to version 1.6.1 (release notes).
Version 1.10.4
October 22, 2021
Fixed
- Fixed an issue in which attributes with spaces before or after the
=
were not being correctly parsed (#178).
Version 1.10.2
October 20, 2021
Fixed
- Fixed a bug in which using
s-action
could throw an exception when parsed (#177).
Version 1.10.1
October 20, 2021
Fixed
- Fixed a bug in which using
s-vals
with JSON encoded variables could throw an exception when parsed (#176).
Version 1.10.0
October 19, 2021
Added
- Added sample components to the playground (#174 ❤️@nystudio107).
Changed
- Increased the minimum required Craft version to 3.3.0.
- The
s-val:*
attribute can now contain square brackets, for examples-val:fields[handle]="value"
. - General performance optimisations.
Fixed
- Fixed a bug in which comments and script tags containing
sprig
could throw an exception when parsed (#3).
Version 1.9.3
October 14, 2021
Fixed
- Fixed multibyte character strings not being correctly converted (#173).
Version 1.9.2
October 11, 2021
Changed
- Optimised the performance and overhead of parsing large Sprig components (#2 ❤️@nystudio107).
Version 1.9.1
October 5, 2021
Fixed
- Fixed an error in the CLI due to an undefined alias in Sprig core (#170).
Version 1.9.0
October 4, 2021
The core functionality of Sprig has been split out into the Sprig Core package.
Added
- Added Craft API autocomplete and documentation to the code editor in the Sprig playground (#157 ❤️@nystudio107).
- Sprig components now pass the token parameter along so that they work seamlessly in a live preview scenario (#162).
Changed
- Split the core functionality of Sprig into the Sprig Core package that can be used by Craft plugins/modules without requiring that the Sprig plugin is installed.
- Removed the
hxDataPrefix
config setting, opting to prefixhx-
attributes withdata-
by default. - Updated htmx to version 1.6.0 (release notes).
- An unminified version of htmx is now loaded from a CDN rather than locally when in a development environment.
- Improved the performance of loading the htmx script from the CDN (#166).
Version 1.8.1
August 27, 2021
Changed
- The
PaginateVariable
class now extends Craft’s Paginate class, adding more functionality and better compatibility with other plugins.
Version 1.8.0
August 23, 2021
Variables passed into Sprig components are now automatically JSON decoded, so you should remove any usage of the
json_decode
filter from Sprig components.
Added
- Added the ability to pass variables as arrays into Sprig components, so you can now do this:
{{ sprig('_components/entries', {entryIds: [1, 2, 3]}) }}
Changed
- Variables passed into Sprig components are now automatically JSON decoded.
Version 1.7.0
July 14, 2021
Added
- Added the s-request attribute that allows you to configure various aspects of the request.
Changed
- Updated htmx to version 1.5.0 (release notes).
- Improved autocomplete suggestions in playground.
Version 1.6.0
June 8, 2021
Changed
- The CSRF token is now regenerated if the password is updated for the current user (#136).
- CSRF tokens are now sent as request headers instead of body params.
- Use of the
javascript:
prefix is disallowed for security reasons and results in an exception being thrown. - Updated htmx to version 1.4.1 (release notes).
Fixed
- Fixed double encoding of ampersands in element attributes (#133).
Version 1.5.2
April 9, 2021
Fixed
- Fixed an error that could occur when registering a new user.
Version 1.5.1
April 9, 2021
Changed
- Sprig overrides the
currentUser
global variable with a fresh version if the current user is updated using theusers/save-user
controller action (#81).
Version 1.5.0
April 7, 2021
Added
- Added the ability to prefix both
sprig
ands-
attributes withdata-
for more valid HTML (#117). - Added the
hxDataPrefix
config setting that forces Sprig to use thedata-
prefix forhx-
attributes. - Added the s-disable attribute that disables htmx processing for a given element and its children.
Changed
- Updated htmx to version 1.3.3 (release notes).
Version 1.4.0
February 24, 2021
- Added the s-headers attribute that allows you to add to the headers that will be submitted with an AJAX request.
Changed
- Updated htmx to version 1.2.1 (release notes).
Version 1.3.2
January 29, 2021
Fixed
- Fixed compatibility with Craft pre version 3.5.0 (#91).
Version 1.3.1
January 13, 2021
Fixed
- Fixed missing variable methods (#79).
Version 1.3.0
January 6, 2021
Added
- Added the following return variables when controller actions are called.
success
(boolean) whether the action succeeded.flashes
(array) flash messages set by the action, keyed by type (notice
orerror
).id
(integer) the ID of the model if one was successfully created/updated.modelName
(model) a model that failed validation, for exampleentry
whenentries/save-entry
fails oruser
whenusers/save-user
fails.
- Added a new s-preserve attribute that ensures that an element remains unchanged even when the component is re-rendered.
- Added a subresource integrity attribute to the htmx script tag when fetching from a CDN for added security.
Changed
- Updated htmx to version 1.1.0 (release notes).
- Requires Craft 3.1.19 or higher.
Removed
- The
sprig.hyperscript
function has been removed. Use the htmx JS API or import hyperscript in your templates manually instead.
Deprecated
- The
errors
variable has been deprecation. Use thegetErrors()
method on the model that is returned when validation fails.
{# OLD way of handling errors #}
{% if errors.title is defined %}
{{ errors.title|first }}
{% endif
{# NEW way of handling errors (assumes `entry` failed validation) #}
{% if entry.hasErrors('title') %}
{{ entry.getFirstError('title') }}
{% endif %}
- The
sprig.element
,sprig.elementName
,sprig.elementValue
andsprig.eventTarget
tags have been deprecated, will each return a blank string since being removed from htmx 1.1.0, and should be removed from templates.
Version 1.2.0
December 14, 2020
Added
- Added a new s-encoding attribute that can be used to set the encoding of requests to
multipart/form-data
for file uploads (#9).
Changed
- Updated htmx to version 1.0.2 (release notes).
Deprecated
- The
sprig.hyperscript
function has been deprecated. Use the htmx JS API or import hyperscript in your templates manually instead.
Version 1.1.1
November 24, 2020
Changed
- Updated htmx to version 1.0.0 (release notes).
Fixed
- Fixed a bug that was preventing the
s-push-url
attribute from being parsed (#62).
Version 1.1.0
November 23, 2020
The
s-vars
attribute has been deprecated for security reasons, use the news-vals
ors-val:*
attribute instead (read the details here). The magic_url
and_events
variables have been removed, use the newsprig.pushUrl()
andsprig.triggerEvents()
functions instead.
Added
- Added new s-vals and s-val:* attributes that add values to a request and that should be used instead of the deprecated s-vars.
- Added a new s-replace attribute that replaces only the specified element in the component.
- Added a sprig.paginate() template variable that paginates an element query.
- Added a sprig.pushUrl() template variable that pushes a URL into the history stack.
- Added a sprig.redirect() template variable that redirects the browser to a URL.
- Added a sprig.refresh() template variable that refreshes the browser.
- Added a sprig.triggerEvents() template variable that triggers client-side events.
Changed
- Updated htmx to version 0.4.0 (release notes).
- Removed the magic
_url
variable, use the newsprig.pushUrl()
function instead. - Removed the magic
_events
variable, use the newsprig.triggerEvents()
function instead. - Made minor tweaks to default playground.
Fixed
- Fixed how array variables are handled in the playground.
Deprecated
- The
s-vars
attribute has been deprecated for security reasons. Use the news-vals
ors-val:*
attribute instead.
Security
- Fixed a potential XSS vulnerability.
Version 1.0.3
October 28, 2020
Added
- Added a config setting to enable or disable the playground on a per environment basis.
Version 1.0.2
October 22, 2020
Added
- Added a warning message if
devMode
is not enabled.
Changed
- Updated htmx to version 0.2.0 (release notes).
Version 1.0.1
October 21, 2020
- Migration schema version release for beta updates.
Version 1.0.0
October 21, 2020
Added
- Added the Sprig playground.
- Added a new Sprig logo.
Version 1.0.0-beta.18.1
October 19, 2020
Fixed
- Fixed an issue with the schema version in project config (#42).
Version 1.0.0-beta.18
October 16, 2020
Added
- Added
beforeCreateComponent
andafterCreateComponent
events toComponentsService
.
Changed
- Duplicate IDs in components no longer throw an error (#40).
- Removed the
sprig.request
template variable, usesprig.isRequest
instead. - Removed the
sprig.include
template variable, usesprig.isInclude
instead.
Version 1.0.0-beta.17
September 25, 2020
Changed
- Uses a HTML5 compatible DOM parser.
Fixed
- Fixed a bug in which HTML tags would be stripped when inside of
<script>
tags (#34).
Version 1.0.0-beta.16
September 18, 2020
Changed
- Uses htmx 0.1.2 and hyperscript 0.0.2 (release notes).
Version 1.0.0-beta.15
September 14, 2020
Changed
- Controller actions that return models are now dealt with accordingly.
Deprecated
- The
sprig.include
template variable has been deprecated and will be removed in version 1.0.0. Usesprig.isInclude
instead. - The
sprig.request
template variable has been deprecated and will be removed in version 1.0.0. Usesprig.isRequest
instead.
Version 1.0.0-beta.14
September 10, 2020
Changed
- Requests to controller actions are now forced to be AJAX requests.
Fixed
- Fixed an error that could occur if a controller action did not return a JSON response (#26).
Version 1.0.0-beta.13
September 3, 2020
Added
- Added the
sprig.hyperscript
tag.
Changed
- Invalid variable exceptions include suggestions for how code could be fixed.
Version 1.0.0-beta.12
September 1, 2020
Added
- Added a default
class="sprig-component"
to all components.
Changed
- An exception is now thrown if an array, object or value that cannot be converted to a string is passed into a Sprig component as a variable.
Version 1.0.0-beta.11
August 18, 2020
The ability to override the component trigger using the
trigger
attribute has been removed. Uses-trigger
instead.
Added
- Added the ability to override all
s-
attributes on the component.
Changed
- Removed the ability to override the component trigger using the
trigger
attribute.
Version 1.0.0-beta.8
July 9, 2020
Added
- Added the
sprig.htmxVersion
variable back in. - Added unit tests to ensure that both local and remote versions of htmx exist.
Changed
- Requires htmx 0.0.8 (release notes).
- Uses the htmx script from unpkg.com unless in a
dev
environment, in which case it uses a local version.
Version 1.0.0-beta.7
July 6, 2020
Added
- Added unit tests.
Changed
- Returns a 400 error when submitted data is determined to be tampered.
- Replaced htmx script from unpkg.com with a local version.
- Removed the
sprig.htmxVersion
variable.
Version 1.0.0-beta.6
July 3, 2020
Added
- Added the
sprig.htmxVersion
variable.
Changed
- Request parameters are now added as variables to the initial sprig include.
- Removed the ability to load extensions using the
sprig.script
tag.
Version 1.0.0-beta.5
July 1, 2020
Added
- Added the ability to pass protected variables into components by prefixing them with an underscore.
Changed
- Requires htmx 0.0.7 (release notes).
Version 1.0.0-beta.4
June 29, 2020
Added
- Added the
s-vars
attribute.
Fixed
- Fixed characters not being encoded in UTF-8 in rendered components (#2).
- Fixed a bug that could throw an error when creating a component class.
Version 1.0.0-beta.3
June 26, 2020
Added
- Added the ability to send events and a URL back in the response header.
- Added the ability to load extensions using the
sprig.script
tag.
Changed
- Renamed the protected property
template
to_template
in the component class. - Removed the
error-url
from the list of available attributes since it was dropped in htmx 0.0.6.
Version 1.0.0-beta.2
June 21, 2020
Version 1.0.0-beta.1
June 15, 2020
- Initial release.