Skip to content

Process non-attribute strings in the dom_str_replace process plugin

Issue #3042833 on drupal.org by benjifisher.

Problem/Motivation

In #2958285: Allow replacing based on a xpath expression, we added the dom_str_replace process plugin, which performs string replacements on attributes of HTML elements in a DOMDocument object. This is a common use case: often we want to modify the href attribute of an <a> element or the src attribute of an <img> element.

It might also be useful to make similar replacements on non-attribute values, such as the inner HTML of a <p> element.

Proposed resolution

Implement processing of other parts of an HTML document, configured using the "mode" option on the dom_str_replace process plugin.

Remaining tasks

User interface changes

None

API changes

None

Data model changes

None