Skip to content

templates:copy-node is missing from the HTML Templating module docs #1304

Description

@duncdrum

templates:copy-node is a real, public function in the html-templating package (confirmed in the installed 1.2.1 package's templates.xqm), but it's missing from the "Pre-defined Template Commands" section of the templating docs page, which otherwise documents templates:include, lib:include, templates:each, templates:if-parameter-set/if-parameter-unset, templates:surround, templates:form-control, templates:load-source (removed), and lib:parse-params.

Signature and current behavior, from templates.xqm:

declare function templates:copy-node($node as element(), $model as item()*) {
    element { node-name($node) } {
        $node/@*,
        templates:process($node/*, $model)
    }
};

A couple of behaviors worth documenting explicitly, since they're easy to get wrong without reading the source (I initially assumed both, incorrectly, before checking):

  • It does not filter @data-template/@data-template-* attributes from the copied node the way templates:process-children/wrapped functions do via templates:filter-attributes - they pass through into the output verbatim.
  • It only recurses into element children ($node/*), not all child nodes - text/comment children of the calling element are dropped, not just re-processed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions