Search code examples
xpageslotus-dominodomino-designer-eclipse

Using HTML5 Boolean Data Attributes in an XPage


When trying to use Boolean Data Attributes (http://www.w3.org/html/wg/drafts/html/master/infrastructure.html#boolean-attribute) in my Xpage I get syntax errors.

The markup snippet:

<label>
    <span>Layout</span>
    <select class="layout-option m-wrap small">
        <option value="fluid" selected>Fluid</option>
        <option value="boxed">Boxed</option>
    </select>
</label>

Causes the following parse error:

Attribute name "selected" associated with an element type "option" must be followed by the ' = ' character.

I have set the doctype to HTML5. How can I fix this error?


Solution

  • A slight modification to Sven's answer did the trick:

    <label>
        <span>Layout</span>
        <select class="layout-option m-wrap small">
            <xp:text escape="true" tagName="option" value="Fluid">
                <xp:this.attrs>
                    <xp:attr name="value" value="fluid" />
                    <xp:attr name="selected" minimized="true" value="" />
                </xp:this.attrs>
            </xp:text>
            <option value="boxed">Boxed</option>
        </select>
    </label>
    

    Generates the HTML:

    <label>
        <span>Layout</span>
        <select class="layout-option m-wrap small">
            <option value="fluid" selected>Fluid</option>
            <option value="boxed">Boxed</option>
        </select>
    </label>