هذه الصفحة غير متاحة بلغة العربية بعد، لذا تُعرض بالإنجليزية.
Marketplace widgets: fields, template and CSS
A widget.json is data: typed fields the owner fills, a logic-less always-escaped template and CSS that the platform scopes to the block. No widget code runs on the server.
A marketplace widget (zmle.widget/1) is a page-builder section. The owner installs it, adds the block Marketplace widget to a page, picks your widget and fills its fields. The platform renders your template with the values, escapes them, runs the output through an allow-list sanitiser and scopes your CSS.
{
"format": "zmle.widget/1",
"name": "Feature cards",
"version": "1.0.0",
"fields": [
{ "key": "heading", "type": "text", "label": "Heading", "default": "Why customers choose us" },
{ "key": "accent", "type": "color", "label": "Accent colour", "default": "#0f766e" },
{ "key": "showNumbers", "type": "boolean", "label": "Number the cards", "default": true },
{ "key": "cards", "type": "list", "label": "Cards", "max": 12, "fields": [
{ "key": "title", "type": "text", "label": "Title" },
{ "key": "text", "type": "textarea", "label": "Text" }
] },
{ "key": "link", "type": "url", "label": "Button link", "default": "/contact" }
],
"template": "<section class=\"fc\"><h2>{{heading}}</h2><ul class=\"fc-grid\">{{#each cards}}<li class=\"fc-card\">{{#if showNumbers}}<span class=\"fc-n\">{{@number}}</span>{{/if}}<h3>{{title}}</h3><p>{{text}}</p></li>{{/each}}</ul>{{#if link}}<a class=\"fc-btn\" href=\"{{link}}\">Contact us</a>{{/if}}</section>",
"css": ".fc-n { background: var(--w-accent); color: #fff; } @media (max-width: 640px) { .fc-grid { grid-template-columns: 1fr; } }"
}| Field type | Value |
|---|---|
text / textarea | A string (≤ max; defaults 200 / 2,000); always printed as text |
url | https://…, /path, mailto: or tel: — anything else becomes empty |
image | https://… or /uploads/…, picked from the media library |
color | #rgb / #rrggbb, also available in CSS as --w-<key> |
number, boolean, select | A number within min / max; true / false; one of options (required) |
list | Items with their own fields (no nested lists) |
- Keys match
^[a-z][a-zA-Z0-9_]{0,31}$, are unique, at most 30 fields;defaultfills new blocks. - Template:
{{key}}(always HTML-escaped),{{#if}} … {{else}} … {{/if}},{{#unless}},{{#each list}}with{{@index}}/{{@number}}; at most 6 nested blocks and 20,000 characters. No{{{raw}}}, helpers or partials; every name must be a declared field. - Refused in the template:
<script>,<style>,<iframe>,<form>,<input>,<link>,<meta>,<base>,<object>,<embed>,on…=handlers, and literal remote files (src="https://…"would track visitors — use animagefield). - CSS is prefixed with the block (
[data-mw="…"] .your-class);url(…),@import,@font-face,expression(),<and backslash escapes are refused; 20,000 characters max.
Written from: docs/DEVELOPERS/WIDGET-SPEC.md, examples/marketplace/widget-feature-cards/widget.json, src/lib/marketplace/widget-core.ts, src/lib/blocks/types.ts