Giter Club home page Giter Club logo

Comments (7)

GuyPie avatar GuyPie commented on May 13, 2024 1

You're right! I had a skip_if that stopped it from working. Sorry, closing this.

from hygen.

jondot avatar jondot commented on May 13, 2024

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.

GuyPie avatar GuyPie commented on May 13, 2024

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.

tobmaster avatar tobmaster commented on May 13, 2024

@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.

GuyPie avatar GuyPie commented on May 13, 2024

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.

tobmaster avatar tobmaster commented on May 13, 2024

Oh, I thought I tried that before. Then sorry for misleading you. I will retry it

from hygen.

tobmaster avatar tobmaster commented on May 13, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.