Skip to content

Render as a string error and convenience method? #8

@Ambient-Impact

Description

@Ambient-Impact

I've noticed that DOM_Query::render() exists, but it gives me a fatal error if I pass false to get the rendered HTML, as the Buffer class is not found.

In addition to that, somewhere along the way the HTML I pass in gets wrapped in <html><body></body></html>, which I have to strip out if I want to render just the structure I passed in. I'm using this in a Drupal project where I'm modifying the output of a field, which is rendered by Drupal as part of its output.

I'm currently using this:

$html = '';

foreach ($DOM->select('body')->contents()->nodes as $node) {
	// Render only the specified node as HTML:
	// https://stackoverflow.com/a/12909924/6513652
	$html .= $node->ownerDocument->saveHTML($node);
}

Would you be interested in me integrating this into DOM_Query::render(), or adding some other convenience method to DOM_Query?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions