BEMJSON → templates → HTML
BEMJSON describes a block: its name, elements, content and modifiers. Edit JSON and compare the HTML, resolved tree and preview. The example uses the real nuckty engine in your browser. The live editor requires JavaScript. Gallery, grid and Markdown examples work without it. 02 / HTML · engine output 03 / PREVIEWTree after templates
How templates change markup
The card template sets article for the block, h2 for its title and p for its description. Block and element names become BEM classes: card, card__title and card__description.
import { block } from 'nuckty';
export default function templates(): void {
block('card')({ tag: 'article' });
block('card').elem('title')({ tag: 'h2' });
block('card').elem('description')({ tag: 'p' });
}
The editor registers these rules in Templates and calls the core render function. Expand “Tree after templates” to inspect the intermediate result before the engine serializes it into HTML.
What to try
- Change
Hello, nucktyin the card: its HTML and preview update immediately. - Add
"mods": { "color": "orange" }to the card object, separated by a comma. The HTML gainscard_color_orange, and the preview uses an orange border and background. - Select “List”. Its
"tightList": trueallows the engine to omit closinglitags in this example. - Select “Button with a modifier” and change
"disabled": truetofalse. The template stops addingdisabled, enabling the button. - Select “Escaping”. Angle brackets become entities in HTML and remain text in the preview.
- Remove a JSON quote to see the error. Restore it or select “Reset”.
The preview uses a separate iframe with an empty sandbox: scripts in the entered HTML do not execute. Editing JSON changes the example; it does not write website source files.