level51 / silverstripe-payload-injector
Utility for injecting JSON payload into the DOM at render time.
Installs: 1 330
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Type:silverstripe-vendormodule
pkg:composer/level51/silverstripe-payload-injector
Requires
- silverstripe/framework: ^4.0
This package is auto-updated.
Last update: 2025-10-20 12:56:22 UTC
README
Utility for injecting JSON payload into the DOM at render time.
Requirements
- Silverstripe 4.x
Installation
composer require level51/silverstripe-payload-injector- Flush config (
flush=all) to register the middleware
Usage
If you do...
public function index() { PayloadInjector::singleton()->stage([ 'title' => 'Silverstripe Payload Injector', 'description' => 'Utility for injecting JSON payload into the DOM at render time.' ]); return $this->renderWidth('MainView'); }
...in a controller you will have...
...
<script>window.payload = {"title":"Silverstripe Payload Injector","description":"Utility for injecting JSON payload into the DOM at render time."}</script>
</body>
</html>
...in your template.
Config
Level51\PayloadInjector\PayloadInjector: merge_recursive: true # Merge payload recursively to avoid overriding existing data (default: true)
Maintainer
- Julian Scheuchenzuber js@lvl51.de