HtmlBlocks / End HtmlBlocks

Takes two parameters, Location, Mode

Description:

Use the HtmlBlocks commands to allow for unescaped raw HTML content inline with your MOX code, with the ability to swap out tags for field names from your Top Query and/or Work Query, including conditional If tags, and to swap out tags for Content.Lang values.

HtmlBlock and HtmlBlocks are identical, except that HtmlBock is a Top Query command that operates a single time using Top Query field names, while HtmlBlocks is a Work Query command that operates once per record in the Work Query and uses Work Query field names, and optionally, Top Query fields as well.

Usage:

HtmlBlocks "Location", "Mode"
HtmlBlocks "Location", ["Append"]
HtmlBlocks ["Runtime"], ["Append"]

Example:

The spaced shown at the start of these HTML tags are only here to enable them to be shown on this page.

HtmlBlocks
    < div class="panel panel-default">  'Example Comment
        < div class="panel-heading">
            < h3 class="panel-title">{{Title}} - {[pCtg]} - {$Hello.World$}< /h3>
        < /div>
        < div class="panel-body">  'Another Comment
            {{Content}}
            {{If Not Content}}< p>No content< /p>{{End If}}
        < /div>
    < /div>
End HtmlBlocks

Details:

Strings in the HTML should be in double quotes, not single quotes, so that the single quotes can be used for trailing comments that will be stripped out like normal MOX code. Single quotes can however be used inside of the double quotes, for example, to help when embedding JavaScript.

Data can be inserted into the HTML content using the following escapes. These are replaced in the HTML content in the order listed here.

  1. Constants and Macros are applied at compile time, following the same rules as other MOX code
  2. {[Example.Name]}    Top Query Field
  3. {$Lang.Alias$}           Content.Lang.Alias (functions the same as Lang$)
  4. {{Example.Name}}    Work Query Field

Although HtmlBlocks do not have any parameters for Field Bases, these blocks will make use of WorkWith and TopWith values if they are set.

HTML content, including content that contains fields, may also be wrapped in conditional If / If Not / End If tags as shown in the example. If and If Not may only use simple bool tests, not complex tests. The scope of the field to be tested is determined by the type of brackets used for the If. If tags of the same type may not be nested but if tags of different types may be tested.

The use of End HtmlBlocks is optional. A Procedure, a Private Method, or Private Function may set HtmlBlocks at the beginning or near the top, and allow the rest of the code to be nothing but HTML.