Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow PPI::Element::insert_before to accept multiple elements, a string or document fragments #150

Open
karenetheridge opened this issue Dec 18, 2014 · 1 comment

Comments

@karenetheridge
Copy link
Contributor

PPI::Element::insert_before is documented as:

In future, this method may be enhanced to allow the insertion of multiple
Elements, inline-parsed code strings or L<PPI::Document::Fragment> objects.

Indeed, this method (and insert_after) appear to be the ideal natural interfaces for inserting a new code snippet into an existing document. Unless I've missed something, the closest that exists today is:

my $element;    # the element in the existing document to insert before
my $doc = PPI::Document->new(\$code_snippet);
$element->insert_before($_) foreach $doc->schildren;
@karenetheridge
Copy link
Contributor Author

Unless I've missed something, the closest that exists today is...

...which doesn't work reliably - see #151.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant