HaXtatic Docs

hax.xmlEscape

Outputs the given content with all occurrences of any of & < > " ' each appropriately entity-escaped for safe inclusion in HTML/XML/etc. markup.

In a nutshell

  1. Declaration of an |X|hax.xmlEscape:myTag directive in a *.haxproj file,
    • further configuring: (no other settings)
  2. Usage anywhere: {X|myTag: any "content' to <> XML&HTML-escape |}

Stage:

Early — this X-renderer does not require a page context for rendering: therefore many hax.xmlEscape-invoking X-tags encountered during pre-templating (at start-up time) may be eagerly processed immediately in-place (for overall-reduced per-page processing loads).

Purpose

As a general principle, none of the built-in X-renderers ever HTML/XML-escape, of their own accord (unless expressly set up to do so on specific occasions), any of their generated outputs derived from project inputs: users are expected to specify such inputs already-escaped as the project's / file's output format demands.

As such, some projects might for example require XML/HTML-escaping other haXtag outputs dynamically/selectively after-the-fact; such is accomplished by embedding them inside a hax.xmlEscape X-tag.

  
…Scroll to: