Docs

The perfect choice for your next project

Overview

You can make your HTML dynamic by using attribute directives as you would in modern web frameworks. When typing most of them Implementation Assistant will notify you to auto-create (if don't exist) required Commands and Providers or to install a Widgets. The vocabulary here is simple, attribute [gc-as] tells what it is and other [gc-*] attributes are parameters. Note: For any naming attributes use camelcase e.g. for a [slot] you would use [gc-name="myAwesomeSlot"].

Layout

Any page requires a container which wraps its content and it is done by using layout directive. Inside the layout you don't have access to store nor to Commands. If that's what you need see Slot. However, several global variables can be accessed:

  • mediaFiles - media files by their names
  • bootstrap - if imported, bootstrap classes
  • fa - if imported, font awesome classes
  • isCalledByPrerender - tells whether the HTML piece is called by prerederer
  • a valid var name which is a local name of imported CSS or global style. See [depenencies] and Global Styles. E.g. if you imported a global styles called myAwesomeTheme, it'll be accessible as variable in the slot. See Extended Tags to see how you can make use of these variables.
  • global.* - window object combined with Global Styles

API

  • top level tag
  • can't be inside one another
gc-as="layout"

Slot

A logical UI piece which has its scoped CSS and is extracted to dedicated file is called slot. It requires a unique (within page) camelcase gc-name. Whatever is in slot gets access to a store, commands and other useful variables. Here is a list:

  • actionResults - store i.e. provider and command results by their names
  • actions - commands by their names
  • mediaFiles - media files by their names
  • styles - local styles scoped just to this slot
  • bootstrap - if imported, bootstrap classes
  • fa - if imported, font awesome classes
  • uiSignals - signal getters and setters. See UI signals
  • isCalledByPrerender - tells whether the HTML piece is called by prerederer
  • a valid var name which is a local name of imported CSS or global style. See [depenencies] and Global Styles. E.g. if you imported a global styles called myAwesomeTheme, it'll be accessible as variable in the slot. See Extended Tags to see how you can make use of these variables.
  • global.* - window object combined with Global Styles

API

  • must be inside layout
  • can't be inside one another
gc-as="slot"
gc-name="${slotName: string}"

Reusable Slots

Very similar to slots, except they don't have content. They are logical UI piece shared accross pages. If you type one, it'll automatically apear under Reusable Slots. It then can be edited in a separate HTML editor and it has its own scoped CSS as well as access to global variables slots have.

API

  • must be inside layout
  • can't be inside one another
gc-as="slot"
gc-name="${slotName: string}"

Conditional

Display the below div if provider shouldDisplaySpan returns true'thy:

Display the below div if provider getUser returns an object with a property isAuthenticated set to true'thy:

Display the below div if command showPanel returns true'thy:

Display the below div if result of command setUserEmail equals to a field email of provider getUser:

Display only content of the below fragment if provider shouldDisplayFragment returns true'thy:

Display the below span if item of a loop over provider getProducts is isOnSale property set to true'thy:

Display the below span if item of a loop over provider getProducts has a property id that equals to result of command setActiveProduct:

Display the below div if props.isConditionMet evaluates to true. See Extended Tags and UI signals:

Apply class coolClass on the span below if signal uiSignals.activeSomething matched the condition. See Extended Tags and UI signals:

API

  • must be inside layout
  • can't be inside one another
gc-as="conditional"
gc-command="${commandName: string}" || undefined
gc-provider="${providerName: string} || undefined"
gc-test-field="${fieldName: string}" || undefined

UI Signals

UI Signals give you local state which can be used to update UI when it changes. They are scoped to a [slot] they are in. Just use global uiSignals variable as below.

On user click, set signal named activeSomething:

Use signals in conditionals See Extended Tags and conditionals:

Use signals to apply classes. See Extended Tags:

API

  • must be inside [slot]

Images

Display image with a hardcoded src:

Image taken from a property image of provider getProduct. Remember to provide example src, also see record field presenter:

Display image taken from a result of provider getProductImage. Rememver to provide examplesrc. Remember to provide example src, also see provider result presenter:

Display image taken from property image of an item when looping over provider getProduct. See list item presenter and list field presenter:

You can display images uploaded to media files pane by using Extended Tags. Since generated code uses Webpack's responsive loader, you can serve the image low quality placeholder for prerendering and otherwise src. Depending on the file mimetype, you'll access sources of *.png, *.jpg, *.jpeg, and *.gif using src (or placeholder) and others by simply mediaFiles['some-file.svg']:

API

  • must be inside slot unless it's a hardcoded src or mediaFiles image
  • can't be inside one another

Video

Display video with a hardcoded src:

Display video taken from property video of provider getProduct. See record field presenter:

Display video taken from a result of provider getProductVideo. See provider result presenter:

Display video taken from property video of an item when looping over provider getProducts. See list item presenter and list field presenter:

You can display videos uploaded to media files pane by using Extended Tags. Just access your file source by global variable mediaFiles by its name. Note that source tags won't render when prerendering your HTML so you don't need to use isCalledByPrerender to prevent prerendering sources:

API

  • must be inside slot unless it's a hardcoded src or mediaFiles video
  • can't be inside one another

Error Presenter

Display message of error SomeError thrown by any command. Remember to provide example message:

API

  • must be inside [slot]
  • can't be inside one another
gc-as="errorPresenter"
gc-error="${errorName: string}"
gc-custom-name || undefined

Record Field Presenter

Display property sku of an object returned by provider getProduct. Remeber to provide example text:

API

  • must be inside [slot]
  • can't be inside one another
gc-as="recordFieldPresenter"
gc-provider="${providerName: string}"
gc-field="${fieldName: string}"

Provider Result Presenter

Display a result of provider getProductSku. Remember to provide example text:

API

  • must be inside [slot]
  • can't be inside one another
gc-as="providerResultPresenter"
gc-provider="${providerName: string}"

Command Result Presenter

Display a result of command setSomeValue. Remember to provide example text:

API

  • must be inside [slot]
  • can't be inside one another
gc-as="commandResultPresenter"
gc-command="${commandName: string}"

List Item Presenter

Display a list of countries taken from provider fetchCountries which returns an array of objects containing property name. Remember to provide example text in the list field presenter.

Whatever is inside it, it gets access to two variables called: providerName + 'Item' and providerName + 'Index' e.g. fetchCountriesItem and fetchCountriesIndex which represent respectively each iteration item and index within the array. See Extended Tags and var presenter.

Notice the use of fragment which allows to render only its content:

Display a dropdown of countries from taken from provider fetchCountries which returns an array of objects containing property name. Remember to provide example text in the list field presenter.

Notice how you can combine different directives and Extended Tags:

This particular directive allows you to auto-generate required provider from HTML if one doesn't exist yet. So, imagine you paste-in a piece of static HTML and add directives only to the first item of the list. All the data will be parsed and used within auto-generated provider.

So this:

will be turned into provider fetchCountries:

API

  • must be inside [slot]
gc-as="listItemPresenter"
gc-provider="${providerName: string}"

List Field Presenter

Display a property name of an item while looping over provider fetchCountries. Use it inside list item presenter. Remember to provide example text. Notice the use of fragment which allows to render only its content but you can use any valid tag if you whish:

API

  • must be inside [slot]
  • can't be inside one another
gc-as="listFieldPresenter"
gc-provider="${providerName: string}"
gc-field="${fieldName: string}"

Var Presenter

Display variable fetchCountriesItem given it's accessible i.e. it's inside a directive which exposes the variable. There are two directives which do so; slot and list item presenter:

Here is more advanced example. Notice you can use fragment to display just its content. Remember to provide example value:

API

  • must be inside [layout]
  • can't be inside one another
gc-as="varPresenter"
gc-name="${varName: string}"

Widget

Display widget form with a role myForm which makes it distinctive within page or reusable slot:

Note: gc-role is used as distinctive identifier to allow using the same widget multiple times on the page or reusable slot and style them independently. There role is scoped to a page or reusable slot where the widget is inserted.

API

  • must be inside [slot]
  • can't be inside one another
gc-as="widget"
gc-name="${widgetName: string}"
gc-role="${roleName: string}"
gc-role[nestedWidgetName: string]="${nestedRoleName: string}"

To display link to a page somePage. Note that text in the a tag will be replaced with what's specified in the page's gc-as="navName" meta tag:

Here is a link:

You can customize its text this way:

API

  • must be inside [slot]
  • can't be inside one another
gc-as="pageLink"
gc-page="${pageName: string}"
gc-custom-name="${customName: string}" || undefined