liveBook · Manning

Placeholder

As explained in Building User-Friendly DSLs

A temporary value that represents the intention to create a new abstract-syntax-tree object before its concept has been chosen.

A placeholder represents an unfinished value or the intention to create a new AST object before its concept and properties are chosen. In an editor projection, placeholder text turns missing data into an explicit call to action rather than an empty or crashing display. section 6.1.1 section 6.4

Implement placeholders by:

  • Creating the new object with its concept and an initially empty settings object. section 6.1.1
  • Guarding expressions that access missing settings so undefined values do not reach string or formatting functions. section 6.1.1 section 6.4
  • Displaying property-specific markers such as <name> and <type>, styling them as missing, and switching to editing on click. section 6.1.1

Rental attributes

Clicking “+ attribute” adds a Data Attribute with empty settings. The projection then shows <name> and <type> until the domain expert supplies the attribute name and type. section 6.1.1 section 6.4

// (existing code:) 
<div className="section"> 
    <div><span className="keyword">attributes:</span></div> 
    {settings["attributes"].map((attribute, index) => 
        <Projection 
            astObject{attribute} 
            ancestors={[ astObject, ...ancestors ]} 
            key={index} 
        /> 
    )} 
    // Add a button: 
    <button 
        className="add-new"       #1
        tabIndex={-1}             #2
    >+ attribute</button>         #3
// (existing code again:) 
</div>

The attribute-creation listing shows the event-driven step that inserts a new AST object before its editable properties are filled. section 6.1.1

How Building User-Friendly DSLs covers it

How deep it goes
Defines the intent and UI treatment, then implements guards, placeholder props, missing-value styling, and click-to-edit behavior.
Examples
Uses a Rental record’s new attributes with <name> and <type> markers as concrete examples.
What it assumes
Assumes editable AST projections and settings, while teaching defensive handling of unset values from the implementation onward.
What you can do after
Build it from scratch by adding unfinished AST objects and rendering safe, actionable editors for their missing properties.
How it connects
Connects placeholders with AST objects, projections, settings, domain experts, and DSL editors.

Also explained in

Compare how 7 books explain placeholder →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building User-Friendly DSLs. The section links point to the parts of the book it draws on.