feat: add dynamic content variables / inline tokens#743
Merged
Conversation
Adds a Global Variables plugin that enables dynamic content variables
(inline tokens) in rich text fields. Variables stored as key-value pairs
are referenced using {variable_key} syntax and resolved server-side
when content is read via the API.
Changes:
- New global-variables-plugin with CRUD API and admin UI
- Variable resolver service with recursive object traversal
- content:read hook type added to HOOKS constant
- Server-side resolution integrated into content GET endpoint
- In-memory caching for variable lookups (5min TTL)
- 13 unit tests for the variable resolver
Part 2 (Quill editor UI for token picker) is planned for a follow-up PR.
Fixes #719
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
|
Would like to add a candidate for a phase 4 - the ability to register functions to these global variables. Think of a calculation of total reviews count, or an api call to calculate something. Internal db relationship resolver, etc. just like a Wordpress short code registry really. |
cp-bwg
added a commit
to cp-bwg/sonicjs
that referenced
this pull request
Apr 8, 2026
…des plugins (SonicJs-Org#756) Implements Part 2 (Rich Text Inline Tokens) from SonicJs-Org#719: - Enhanced global-variables-plugin with full CRUD admin page, Quill blots (blue chips), TinyMCE PluginManager integration, and editor toggle - New shortcodes-plugin with [[shortcode]] syntax, handler registry, CRUD admin, live preview, Quill blots (purple chips), and TinyMCE support - Shared editor utilities: Quill constructor Proxy, searchable picker dropdown, TinyMCE PluginManager approach, admin HTML template - Content resolution: variables (priority 50) → shortcodes (priority 60) - 5 built-in shortcode handlers: current_date, phone_link, cta_button, plan_count, provider_rating Closes SonicJs-Org#719 Extends SonicJs-Org#743 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This was referenced Apr 8, 2026
lane711
pushed a commit
that referenced
this pull request
Apr 9, 2026
…des plugins (#756) Implements Part 2 (Rich Text Inline Tokens) from #719: - Enhanced global-variables-plugin with full CRUD admin page, Quill blots (blue chips), TinyMCE PluginManager integration, and editor toggle - New shortcodes-plugin with [[shortcode]] syntax, handler registry, CRUD admin, live preview, Quill blots (purple chips), and TinyMCE support - Shared editor utilities: Quill constructor Proxy, searchable picker dropdown, TinyMCE PluginManager approach, admin HTML template - Content resolution: variables (priority 50) → shortcodes (priority 60) - 5 built-in shortcode handlers: current_date, phone_link, cta_button, plan_count, provider_rating Closes #719 Extends #743 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a Global Variables plugin that enables dynamic content variables (inline tokens) in rich text fields. Variables are stored as key-value pairs and referenced using
{variable_key}syntax, with server-side resolution when content is read via the API.This implements Part 1 (Global Variables Collection) and Part 3 (Server-Side Resolution) from #719. Part 2 (Quill editor UI for token picker) is planned for a follow-up PR.
Changes
global-variables-plugin— core plugin with:global_variablesSQLite table (key, value, description, category, is_active)GET/POST/PUT/DELETE /api/global-variablesGET /api/global-variables/resolveendpoint for flat key→value map/admin/global-variables{variable_key}token replacement in strings, objects, and arraysGET /api/content/:idnow resolves variables in content data (opt-out via?resolve_variables=false)CONTENT_READhook — new hook type added to the HOOKS constant for plugin extensibilityTesting
Caveats
GET /api/content/:id— list endpoints can be extended in future[a-z0-9_]to avoid conflicts with HTML/JSON syntaxFixes #719