Giter Site home page Giter Site logo

Pass custom json to actions about plop HOT 7 CLOSED

plopjs avatar plopjs commented on August 16, 2024
Pass custom json to actions

from plop.

Comments (7)

amwmedia avatar amwmedia commented on August 16, 2024

so when you run a plop generator... you want to type json into the console? I'm not sure I understand the want here.

from plop.

fleed avatar fleed commented on August 16, 2024

Sorry, I should have specified it better.
I'm expecting to load data from a json file which is "side-by-side" with templates.
I'm able to do it with yeoman, but I prefer the plop approach that keeps data and templates together with my source code.

from plop.

amwmedia avatar amwmedia commented on August 16, 2024

interesting feature, so this would allow you to have a template that renders differently depending on the json data that is next to it I guess?

plop doesn't currently support this, but it sound like it could be worth adding. πŸ˜„

from plop.

fleed avatar fleed commented on August 16, 2024

Happy to hear that you'll consider it!
A little bit more context: I'm a C# developer and I was convinced (and I proved it) that 60% of our code had patterns perfect for code generation or, if you wish, "continuous scaffolding".
I've defined a metadata small file and used Microsoft T4 to "continuously scaffold" entities (POCO objects), object mappers, data layer, (WCF) data services, etc.. When I find a bug, I can fix it in the template, regenerate the code and it's fixed everywhere (but it's also true the other way round you introduce a bug everywhere..). Partial classes in C# allow me to extend the generated part with custom code.
As we're moving to REST APIs I'd like to do the same but outside Visual Studio/pure .NET world, and I've started using yeoman.
Yeoman is anyway limited (I can't "nest" templates) and it's also hard to make it work in a "continuous" way. That's how I've found plop.
What I'm missing in Plop too is the possibility to get data "statically" (from a Json file, instead of prompting the user) and also the possibility to "nest" templates.
An example of nested template is the definition of a C# class: one template defines the class using the relative object, but internally I will use one or more property templates to generate the array of properties defined. That's what I mean for "data flowing from one generator to another".
I hope it helps and I would be glad to help if possible.

from plop.

amwmedia avatar amwmedia commented on August 16, 2024

I see, it sounds like what you want to do could be pretty easily achieved with node-plop once I finish it. I've got a version that's pretty close to ready, but not quite there yet. It basically take the core functions of plop, and makes them usable from a node script. So you should be able to code up something like what you want to do in a custom node script and let node-plop take care of the heavy lifting. I'll let you know once I have the first version up.

from plop.

fleed avatar fleed commented on August 16, 2024

Sounds very powerful.. Thanks!

from plop.

amwmedia avatar amwmedia commented on August 16, 2024

please take a look at node-plop. It's available now, not well documented, but I'd consider it pretty stable at this point.

from plop.

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.