Skip to main content
Version: v1 (Current)

GxP Strings Plugin

The strings plugin replaces leaf-element text and media sources with values from the GxP store. This lets project admins configure content without changing the component. Declare the keys in the manifest and expose their matching admin fields; markup alone does not create saved configuration.

This reference compares toolkit 2.1.40 with platform revision 5cf2925bcbb58fc397205ac553d7827ccab4c996, with the runtime baseline reviewed on 2026-10-14 and the toolkit guidance delta reviewed on 2026-10-15. Both support these bindings, with differences in store resolution, root processing, dynamic keys, and cleanup described below.

Overview​

BindingDefault source / effect
gxp-string="key"Reads text from stringsList and replaces textContent
gxp-src="key"Reads an asset URL and replaces src
v-gxp-string="'key'"Explicit Vue text directive
v-gxp-src="'key'"Explicit Vue source directive

Source switches such as gxp-settings and gxp-state are ordinary attributes. They are not Vue's .settings/.state directive modifiers. Keys are case-sensitive. Use stable, descriptive names.

Installation​

The local runtime and platform host register the plugin. A normal app should use the supplied directives rather than register a second strings plugin or bundle the toolkit's runtime into its production output.

For runtime development, the local factory is createGxpStringsPlugin(store, { devServerBaseUrl }). The platform factory resolves the active page/widget store through the component provide chain, then the host bridge, then a supplied fallback store. A single local store does not prove multi-widget isolation.

Basic Usage​

Text Content (gxp-string)​

Use a leaf node with meaningful fallback text:

<h1 gxp-string="welcome_title">Welcome</h1>
<button><span gxp-string="increment_label">Increase</span></button>

The plugin captures initial text as its fallback. A truthy configured value replaces it, and reactive store changes update the processed element. Replacing textContent removes existing child nodes, so put the binding on a dedicated span when a button contains icons or other markup. It is text replacement, not a rich-HTML rendering interface.

Image Sources (gxp-src)​

<img gxp-src="hero_image" src="/src/public/hero.svg" alt="Welcome illustration" />

This fragment assumes you created src/public/hero.svg and declared an assets.hero_image value/selector. A configured URL replaces src; otherwise the original source is the fallback. The local runtime can prefix a root-relative fallback with its dev-server origin, which matters for portal injection. Store-returned URLs are not automatically prefixed there. Test the final installed asset URL after packaging.

Changing src does not set alt, check that an image exists, upload an asset, or validate media access. Keep alt text and error/empty states explicit.

Store Sections​

Strings (stringsList)​

Default text comes from the selected strings map. For local development, declare strings.default in the manifest. Other locale maps accepted by schema are not automatically selected by the local loader. Verify the installed portal's language behavior separately.

Settings (pluginVars)​

Use gxp-settings to select a setting:

<span gxp-string="company_name" gxp-settings>Demo Event</span>

Pair it with a settings.company_name configuration field. Use a computed getter if a numeric/boolean value must be displayed exactly, including zero or false.

Assets (assetList)​

gxp-src uses the asset lookup by default. gxp-string="key" gxp-assets can display an asset URL as text. Platform lookup can include static packaged assets; a blank dynamic asset falls through.

Trigger State (triggerState)​

Use gxp-state for state-backed text or media:

<span gxp-string="current_status" gxp-state>idle</span>
<img gxp-src="badge_image" gxp-state src="/src/public/placeholder.svg" alt="Badge preview" />

These are fragments; create the referenced fallback file first. Update shared plugin state with store.triggerState[key] = value. The local updateState and updateSetting aliases are not platform exports. State edits do not persist or broadcast a server change automatically.

At platform 208d36e1b5 (reviewed 2026-11-05), gxp-state="<identifier>" reads a bound portal widget's state from widgetStates instead of the page's own triggerState; a bare gxp-state is unchanged:

<span gxp-string="now_playing" gxp-state="jukebox_widget">Nothing playing</span>

The identifier is the dependency that binds the widget. The element shows its fallback when the widget is not in widgetStates. Toolkit 2.1.47 supports the identifier with local widget fixtures. See portal widgets as shared state.

Directive Reference​

gxp-string​

Source attributeSource
NonestringsList
gxp-settingspluginVars
gxp-assetsAsset lookup
gxp-statetriggerState

gxp-src​

Source attributeSource
NoneAsset lookup
gxp-statetriggerState

The source is selected by attributes on the element. Use one source switch. Combined attributes have an implementation-defined priority; they do not merge values or provide multiple fallbacks.

Dynamic Updates​

From Code​

Shared setters updateString, updatePluginVar, and updateAsset change reactive values only. Use direct triggerState mutation for temporary state. Persist admin content or platform records through the appropriate platform workflow. Host navigation/reload can replace runtime values.

From Dev Tools​

Use the local Store Inspector to simulate settings, text, assets, and guest state. Those edits are preview data. Test the actual configured release, principal, and asset URL in an installed project before releasing it.

From Manifest Hot Reload​

The local runtime processes Vite manifest-update events without requiring a page refresh. Reload replaces declared defaults and can reset temporary state and unsaved local form data. Malformed JSON or a disconnected HMR session needs separate diagnosis; a preview that still displays old content is not proof that the new manifest was applied.

Fallback Behavior​

Both reviewed implementations use a truthiness check for text replacement:

Store valueText with a nonempty fallback
Nonempty stringConfigured text
String "0"0
Empty string, numeric 0, or falseOriginal fallback
Missing/null valueOriginal fallback

This differs from getString, getSetting, and getState, whose nullish fallbacks preserve empty strings/zero/false. For exact numeric/boolean output or deliberately blank text, use a Vue expression/computed getter and explicit formatting. Avoid an empty initial fallback: in repeated raw processing, already-inserted content can become the fallback.

For gxp-src, a falsy value falls back to the original source when present. With no fallback source, clearing a value may leave the previous src in the local implementation. Provide an intentional fallback or manage src explicitly when removal matters.

Attribute Syntax​

Raw attributes are processed by the component mixin. The local implementation scans descendants of the component root; the platform also handles the root and fragment roots. For portable local behavior, use a plain wrapping container with bindings on its descendants, or explicit Vue directives on leaf elements. A raw binding only on the local component root can be missed.

<template>
<section>
<h1 v-gxp-string="'welcome_title'">Welcome</h1>
<p gxp-string="company_name" gxp-settings>Demo Event</p>
</section>
</template>

Use this complete component with the starting manifest/configuration from App Manifest. No script is needed because the host installs the plugin. A quoted literal in v-gxp-string is a key; an unquoted identifier is a Vue expression.

Multiple Modifiers​

Choose one source attribute per element. The reviewed text implementation prioritizes state, then settings, then assets, then strings; combining attributes does not compose content. Changing source attributes dynamically is not a portable subscription contract. Prefer stable elements or a computed expression for that behavior.

Use with Vue Bindings​

A directive can read a Vue expression as its key, but the local watcher is established for the original key. A changed key can display once and then revert to the old key after a later store-map update. Keep keys stable or remount the element with a corresponding Vue :key; use computed getters for a fully dynamic selection. Verify the installed implementation too.

Vue bindings such as :class and :alt remain independent of text/source replacement. Avoid having Vue and the plugin both own the same element's text or src. Prefer one mechanism for each value.

Programmatic Processing​

Runtime developers can call processGxpStrings(rootElement, store) and processGxpSrcs(rootElement, store, devServerBaseUrl) in the toolkit. The platform's source processor has no dev-origin parameter and resolves the active host store before the passed fallback. These are implementation utilities, not a reason to duplicate host registration.

Utility Functions​

getGxpStringKey(element) reads its raw gxp-string attribute; hasGxpString(element) checks for that attribute. They do not evaluate a Vue directive expression or extract all dynamic keys from source code.

Performance Considerations​

Watchers​

Bindings create watchers; local watchers can observe the entire source map as well as the selected key. Limit unnecessary bound elements in large lists. A computed shared label or a Vue getter can avoid repeated replacement and preserve zero/false semantics.

Explicit Vue directives stop their watcher in the unmounted hook. The raw attribute processors do not expose an equivalent automatic per-element cleanup guarantee for all manual/removed DOM cases. Prefer explicit directives for repeatedly created/removed elements, and test lifecycle behavior if using manual processors.

Initial Load​

Fallback content can appear before asynchronous configuration arrives. Handle loading explicitly if that transition matters; do not promise there will be no visual change or that old fixture content cannot flash.

Best Practices​

1. Always Provide Fallbacks​

Use meaningful leaf-element fallback text and actual accessible media. Use Vue expressions for intentional blanks and numeric/boolean output.

2. Use Descriptive Keys​

Keep stable names such as welcome_title, company_name, and hero_image. Avoid changing a binding's key/source without handling its subscription.

Declare text under strings.default and matching admin fields. Verify translation and installation values rather than treating a schema-accepted locale map as a working language switch.

4. Use Dev Assets for Images​

Development placeholders and packaged asset_dir files are separate from installed selected assets. Check all required files and final resolved URLs; addDevAsset creates a localhost URL without uploading/packaging its target.

5. Scan for Hardcoded Strings​

Use the current extraction workflow:

gxdev extract-config --dry-run
gxdev extract-config
gxdev lint --all

Use ./node_modules/.bin/gxdev for a project-local toolkit. Inspect the diff before applying it. The extractor uses regexes, can miss dynamic/complex markup, and seeds keys rather than creating a complete admin form or permission binding. Existing blank strings/assets can be filled even without --overwrite; malformed-manifest recovery and CLI writes need review. See manifest validation.

Troubleshooting​

Strings not updating​

Check the selected store, key/source attribute, and configuration load. A key/source that changed after watcher creation needs remounting or a computed getter. Confirm a raw attribute is on a processed descendant locally.

Fallback always showing​

Check for missing/null/empty/zero/false values and source priority. Inspect strings.default and installation values. A getter returning zero and a text directive showing fallback can both match the current implementation.

Images not loading​

Check the source file/URL, fallback, chosen asset binding, response status, and final package contents. An inaccessible configured URL is still a value; the strings plugin does not replace it after an image-load error.

Hot reload not working​

Check JSON validity and the Vite connection. Watch manifestError locally, then reload if necessary. Do not use that local-only field in production plugin logic.

Performance issues​

Reduce unnecessary bindings and whole-map changes, prefer Vue computed values for exact data display, and verify repeated mount/unmount cycles.