Views specs

Spec version 1.0.0-alpha.0

Why?

His goal is to describe a particular view like hello.twig. By describing the data that this view depends on, you can use that and build your backend automatically. Pretty usefull for medium/large projects.

Filename

A specification file has to be named with .spec.json at his end. Usually this mean that if you have a view named card.twig, the files will be something like this:

| src
  | views
    | components
      | card
        | card.twig
        | card.spec.json

Structure

Here's an example of the card.spec.json file and how it can be written:

Note that the "cta" property is set to @sugar.views.components.cta. This is a link to another existing spec file that is available from the @coffeekraken/sugar package. To read a spec file, make use of the @coffeekraken/s-specs package that will resolve these links for you.

Data types

Here's the main data types that we think cover a lot of situations. Note that this is more to take as example that final types. You can specify your own types as well depending on your needs:

  • String: Simple string data
  • Text: Similar as "String"
  • Wysiwyg: String that can contain formatting tags
  • Date: Simple ISO date string
  • DateTime: Simple ISO datetime string
  • Time: Simple ISO time string
  • Number: Simple number
  • Integer: Simple integer number
  • Image: Simple image data
    • src: The source of the image
    • alt: The alternative text
    • title: The image title
  • Object: An object described by his own props

Repeatable types array

To define a prop as repeatable, simply suffix his type with [].

Here's a simple example

Resulting data

If we take the overview example above, the resulting data that has to be injected into the view at his render phase could be something like this:

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