-
Notifications
You must be signed in to change notification settings - Fork 249
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
Inject multiple times to the same file #36
Comments
Hi! currently this is by design. Multiple different injections require multiple different files. If you have a ton of injections, which make up most of the content of a file, consider rebuilding the entire file with generators each time. |
That was fast! Unfortunately re-generating the entire file isn't possible for me, specifically what I'm trying to do is add an import to a file and then use that import, so I need to insert two non-consecutive lines, but I don't want the rest of the file to change, nor can I tell what its current content is. |
@GuyPie You can write multiple template files that target the same file but different before/after locations.
02_inject_b_file.txt
That way you should be able to achive your goal while separating the different "concerns". Hope it helps |
Thanks @tobmaster, but that's exactly what I tried initially and it doesn't work - what ends up happening is only one the injections takes effect. |
Oh, I thought I tried that before. Then sorry for misleading you. I will retry it |
I retried it successfully in hygen 1.4.8 with this: It produced in some/target.txt
Have you checked the regex for insertion? |
You're right! I had a skip_if that stopped it from working. Sorry, closing this. |
When trying to inject multiple times to the same file, only one of the injections applies.
The text was updated successfully, but these errors were encountered: