Data

To render a view, you certainly need some data. This is handled by the %viewName.data.js files.

Supported data file types

For now, your can use these formats:

  • filename.data.json
  • filename.data.js
  • filename.data.php

These data files are handled under the hood by the @coffeekraken/s-data-handler-generic package.

Simple example

Assume that you have a view stored here: src/views/hello/hello.blade.php (it can be a twig as well).

Let's create a new src/views/hello/hello.data.js file with this content:

This will provide the hello variable to your view. You can use it like so:

Passing parameters

To access your parameters from your .data.js file, assume we have this page configuration:

Assume we access our page with this url: /hello/coco/world

In your newly created src/views/hello/hello.data.js data file, access your parameters like so:

From this point, you can handle pretty much all your data needs.

  • Async functions are supported as well

Data files can be in .data.js as well as .data.json and .data.php formats.

Bugs
are not our friends...

Don't hesitate to declare an issue if something does not works as expected.

Declare my issue on Github Talk about it on Discord

The more we are,
the stronger we become.

Don't hesitate to tell some words to you friends about us. The goal is to became more and more each days to help each others...

Support us on Patreon! Share on Facebook! Make a tweet!

The more we are,
the stronger we become.

Don't be afraid to join us on Discord.

Join us on discord!

We love,
Open source!

All of our codebase can be found on Github. We hope that you may contribute to help us make our tools even better!

Discover our codebase!

Welcome on