You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@royale.apache.org by Harbs <ha...@gmail.com> on 2020/01/14 00:07:31 UTC

Writing "HTML" in MXML

I just realized that it’s possible to write almost bog-standard html in MXML files.

The trick was to enable lowercase HTML element names (a change I just committed to the HTML package) and use a default namespace.

Here’s an example file which compiles perfectly:

<sp:SVGIcon xmlns:fx="http://ns.adobe.com/mxml/2009"
  xmlns:sp="library://ns.unhurdle.com/spectrum" xmlns="library://ns.apache.org/royale/html">
  <g fillRule="evenodd">
  <path fillRule="nonzero" d="M16.5,2 L14,2 L14,0.5 C14,0.223857625 13.7761424,0 13.5,0 L12.5,0 C12.2238576,0 12,0.223857625 12,0.5 L12,2 L5,2 L5,0.5 C5,0.223857625 4.77614237,0 4.5,0 L3.5,0 C3.22385763,0 3,0.223857625 3,0.5 L3,2 L0.5,2 C0.223857625,2 3.38176876e-17,2.22385763 0,2.5 L0,15.5 C3.38176876e-17,15.7761424 0.223857625,16 0.5,16 L16.5,16 C16.7761424,16 17,15.7761424 17,15.5 L17,2.5 C17,2.22385763 16.7761424,2 16.5,2 Z M16,15 L1,15 L1,3 L3,3 L3,3.5 C3,3.77614237 3.22385763,4 3.5,4 L4.5,4 C4.77614237,4 5,3.77614237 5,3.5 L5,3 L12,3 L12,3.5 C12,3.77614237 12.2238576,4 12.5,4 L13.5,4 C13.7761424,4 14,3.77614237 14,3.5 L14,3 L16,3 L16,15 Z"/>
    <polygon fillRule="nonzero" points="5 7 3 7 3 5 5 5"/>
    <polygon fillRule="nonzero" points="8 7 6 7 6 5 8 5"/>
    <polygon fillRule="nonzero" points="11 7 9 7 9 5 11 5"/>
    <polygon fillRule="nonzero" points="14 7 12 7 12 5 14 5"/>
    <polygon fillRule="nonzero" points="5 10 3 10 3 8 5 8"/>
    <polygon fillRule="nonzero" points="8 10 6 10 6 8 8 8"/>
    <polygon fillRule="nonzero" points="11 10 9 10 9 8 11 8"/>
    <polygon fillRule="nonzero" points="14 10 12 10 12 8 14 8"/>
    <polygon fillRule="nonzero" points="5 13 3 13 3 11 5 11"/>
    <polygon fillRule="nonzero" points="8 13 6 13 6 11 8 11"/>
    <polygon fillRule="nonzero" points="11 13 9 13 9 11 11 11"/>
    <polygon fillRule="nonzero" points="14 13 12 13 12 11 14 11"/>
  </g>
</sp:SVGIcon>

The only difference between everything below the g and standard SVG markup is the use of “filRule” instead of “fill-rule”.

I wonder if there’s any way we can get the compiler to recognize “kebab-case” in MXML as the same as “camelCase” members in classes.

Being able to copy-paste HTML with no modification into an MXML file is huge!

Harbs