putyourlightson/craft-sprig-core

A reactive Twig component framework for Craft.

Fund package maintenance!
bencroker

Installs: 240 536

Dependents: 7

Suggesters: 0

Security: 0

Stars: 4

Watchers: 3

Forks: 7

Open Issues: 0

Type:craft-module


README

Stable Version Total Downloads

Sprig Core Module for Craft CMS

This module provides the core functionality for the Sprig plugin, a reactive Twig component framework for Craft CMS. If you are developing a Craft plugin/module and would like to use Sprig in the control panel, then you can require this package to give you its functionality, without requiring that the site has the Sprig plugin installed.

First require the package in your plugin/module's composer.json file.

{
  "require": {
    "putyourlightson/craft-sprig-core": "^2.0"
  }
}

Then bootstrap the module from within your plugin/module's init method.

use craft\base\Plugin;
use putyourlightson\sprig\Sprig;

class MyPlugin extends Plugin
{
    public function init()
    {
        parent::init();

        Sprig::bootstrap();
    }
}

Then use the Sprig function and tags as normal in your control panel templates.

{{ sprig('_components/search') }}

If your plugin/module registers an asset bundle that depends on htmx being loaded, ensure that you specify the HtmxAssetBundle class as a dependency.

use craft\web\AssetBundle;
use putyourlightson\sprig\assets\HtmxAssetBundle;

class MyAssetBundle extends AssetBundle
{
    public $depends = [
        HtmxAssetBundle::class,
    ];
}

Sprig plugin issues should be reported to https://github.com/putyourlightson/craft-sprig/issues

Sprig plugin changes are documented in https://github.com/putyourlightson/craft-sprig/blob/develop/CHANGELOG.md

Documentation

Learn more and read the documentation at putyourlightson.com/plugins/sprig ยป

To see working examples and video tutorials, visit the learning resources.

License

This package is licensed for free under the MIT License.

Requirements

This module requires Craft CMS 3.1.19 or later, or 4.0.0 or later, or 5.0.0 or later.

Installation

Install this package via composer.

composer require putyourlightson/craft-sprig-core

Created by PutYourLightsOn.