Sitevision Developer
Log in

Log in

Configuration in RESTApps

Page content

config/

RESTApp configuration files are stored in the config folder.

  • src/
    • config/
      • index.html *required
      • index.js
      • config.js
      • config.css

Configuration is retrieved in a RESTApp server side context through the appData-object.

index.html

index.html is the only required file in the RESTApp configuration. This template defines the keys and values for the configurable values in the RESTApp.

index.js

If the RESTApps configuration requires a context implement index.js. E.g. translated texts (i18n), values from another system or information about the current page.

config.js

If the configuration requires dynamic client side functionallity (e.g. validation feedback) implement config.js.

config.css

Add custom CSS for the configuration panel.

Declaring default values

Default appData values are declared in "appDataDefaults.json" stored in the root of the app.

The default value will be used until there is a value configured by a user. Once a value is saved from the configuration, the default value will never be used again, even though a value might be cleared.

Sitevision identifers should never be used as default values.

Accessing configured values

After values are set in the RESTApp's configuration, values are available though appData.

AppData

AppData holds the local values configuered in the RESTApp. See appData for documentation.

i18n

The i18n function is available when rendering if the index.html file is evaluated as an underscore template, i.e. when an index.js file is present.

The app's default language bundles will be used.

<%= syntax delivers an unescaped string. Use with caution.

The i18n function is also available server side in index.js.

Config Example App

A WebApp demonstrating configuration is available in Sitevision's GitHub repository.

Did you find the content on this page useful?