HTML & Script Wrappers

standard/htmlScript.ftl

Wrapping HTML, such as the boiler plate html head content or the javascript definition tags have been
enhanced in order to strip templates from unneccessary information. Additional options are available
for each element.

Included by htmlTemplate.ftl.

NOTES:

  • May have implicit dependencies on other parts of Scipio API.

Definitions:

commonElemAttribStr,
commonElemEventAttribStr,
htmlHeadOpen,
requireScriptOfbizUrl,
script,
scripts


HTML Head Open

macro htmlHeadOpen

Opens an HTML document and header section.

IMPL NOTE:
Beware of whitespace.

Usage Examples

    <@htmlHeadOpen />

Parameters

includeDocType ((boolean), default: false)
Whether to include doctype or not

Default is false because is already included by screen renderer in @renderScreenBegin.
passArgs

NOTE: This macro implements an advanced arguments interface supplementing
regular macro invocations. See standard/htmlTemplate for details.


Scripts

macro scripts

Optional scripts include modifier. Modifies the @script calls within it.

NOTE:
This is NOT associated with any HTML element nor does it define any.

Usage Examples

    <@scripts output=true> <#- guarantees the @script calls will output content to page at this location ->
      <@script>
        jQuery(document).ready(function() {
            alert("Page loaded.");
        });
      </@script>
      <@script>
        jQuery(document).ready(function() {
            alert("Test.");
        });
      </@script>
    </@scripts>

Parameters

scriptType, output, data, htmlwrap Default arguments for child script calls; see @script
cdata
passArgs

NOTE: This macro implements an advanced arguments interface supplementing
regular macro invocations. See standard/htmlTemplate for details.


Script

macro script

Inline script wrapper. By default, makes a javascript block.

NOTE:
Unlike others, this macro explicitly currently cannot support open/close structure (only htmlwrap).

Usage Examples

    <@script>
        jQuery(document).ready(function() {
            alert("Page loaded.");
        });
    </@script>

Parameters

type (default: "text/javascript")
Script type identifier
src Source document address (when no nested content)
language DEPRECATED by HTML – ignored by macro
output ((boolean))
If true, the script must be output in the markup where the macro is used and should never be delegated

In cases of scripts within common templates,
this should be omitted, except when used in html <head> or in a footer.
If not specified or "", scipio decides what to do with them (output or accumulate at bottom of page).
htmlwrap ((boolean), default: true)
If false don't include HTML wrapper (or cdata)
cdata ((boolean), default: true)
If false don't include CDATA guard (only used if htmlwrap true)
passArgs

NOTE: This macro implements an advanced arguments interface supplementing
regular macro invocations. See standard/htmlTemplate for details.


requireScriptOfbizUrl

macro requireScriptOfbizUrl

Informs the rendering process (decorator) that the given ofbiz URI must be made available to javascript
code.

Normally the getOfbizUrl(url) Javascript function will be used to do this.

The screen/ftl has to communicate to the decorator which URIs it needs to use, so
this is one such mechanism

Ideally this shouldn't needed and getOfbizUrl should just work, but URLs are generated
dynamic using controller request defs and can't predict URL patterns unless rewrite
@pageUrl in JS.

Parameters

url Controller request uri
output ((boolean))
If true, forces the macro to write the markup/content immediately

Prevents delegating this script include. In most template usage this should be omitted.
htmlwrap ((boolean), default: false)
Whether to wrap in @script

NOTE:
Default is FALSE for this macro (unlike others).

onlyIfExists ((boolean), default: false)
Whether to omit URL if not defined in controller

If true, the require request will not produce an entry if the controller
doesn't support the given URI. If false, it will always try to make a URL,
which if missing from controller may give a lot or other error.
uri


commonElemEventAttribStr

macro commonElemEventAttribStr

Prints a string of JS events as HTML element attributes for common macro HTML elements.
Accepts attrib names as both "onxxx" and "xxx".

NOTE:
2016-09-28: The attributes are now automatically HTML-escaped, but NOT javascript-escaped;
caller must identify and escape the JS parts as needed (not trivial).

Parameters

events ((map))
Map of event names to actions
escapeLang


commonElemAttribStr

macro commonElemAttribStr

Prints a string of element attributes for common macro HTML elements.
This is nearly the same as elemAttribStr but with different defaults and with more versatile attribs map.

NOTE:
2016-08-30: The special token values _EMPTY_VALUE_ and _NO_VALUE_ are now considered deprecated;
use #attribSpecialVal instead.
NOTE:
2016-09-30: This now automatically HTML-escapes attribute values by default; see escapeLang parameter.

Parameters

attribs ((map))
Attribs map

The attribs map here is more versatile and supports mergeArgMaps functions more easily.
See function getAttribMapAllExcludes for implementation details.
noExclude ((list))
Prevents excludes of attribs with specified names
includeEmpty See @elemAttribStr; mostly same parameters but with different defaults.
emptyValToken See @elemAttribStr; mostly same parameters but with different defaults.
noValToken See @elemAttribStr; mostly same parameters but with different defaults.
exclude See @elemAttribStr; mostly same parameters but with different defaults.
attribNamePrefix See @elemAttribStr; mostly same parameters but with different defaults.
alwaysAddPrefix See @elemAttribStr; mostly same parameters but with different defaults.
attribNamePrefixStrip See @elemAttribStr; mostly same parameters but with different defaults.
attribNameSubstitutes See @elemAttribStr; mostly same parameters but with different defaults.
camelCaseToDashLowerNames See @elemAttribStr; mostly same parameters but with different defaults.
escapeLang See @elemAttribStr; mostly same parameters but with different defaults.