Comments (7)
You're right! I had a skip_if that stopped it from working. Sorry, closing this.
from hygen.
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.
from hygen.
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.
from hygen.
@GuyPie You can write multiple template files that target the same file but different before/after locations.
e.g:
01_inject_a_file.txt
---
to: path/to/file.txt
inject: true
after: LOCATION_A
---
first injection
02_inject_b_file.txt
---
to: path/to/file.txt
inject: true
after: LOCATION_B
---
second injection
That way you should be able to achive your goal while separating the different "concerns".
Hope it helps
from hygen.
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.
from hygen.
Oh, I thought I tried that before. Then sorry for misleading you. I will retry it
from hygen.
I retried it successfully in hygen 1.4.8 with this:
https://gist.github.com/tobmaster/8489f1b0a850216c73c2619144a69e90
It produced in some/target.txt
We say:
Salve
Hello
to
- John
- Maria
Have you checked the regex for insertion?
from hygen.
Related Issues (20)
- How to ignore template directories?
- Could I have some order about when each template should be executed?
- [Question] Is hygen only for JS or is it language agnostic HOT 2
- [Docs] www.hygen.io does not redirect HTTP --> HTTPS
- how to just create a folder? without any files? HOT 2
- SSL for Homepage in Docs
- Inject multiple node dependencies within one template, each with dedicated skip_if's HOT 1
- pnpm HOT 2
- Issues triage question -- still under development? HOT 1
- Skip some or all prompts according to variables defined in template file?
- Hygen parsing templates not in the specified folder path HOT 1
- Inject "after" skips extra line
- Help Wanted - Generator Fails Inconsistently Without Any Indication Of Error
- fail to load custom template path
- Project with type Modules skips index.cjs HOT 3
- skip_if needs to support variable HOT 3
- hygen vs code extension?
- [BUGFIX] whitespace error with frontmatter section
- FAQ Toggle Issue
- Kindly asking... is this still maintained? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hygen.