Git Product home page Git Product logo

Comments (9)

brettcannon avatar brettcannon commented on June 1, 2024 1

I have somewhat run into a need for this as I have a template with some repeated, complicated Jinja templating that I don't want to make into one explicit Jinja plugin that people have to depend on so as to not gain a dependency on my template. It would be great if from some hook I could directly manipulate the Jinja context to inject my own items and plugins.

from cookiecutter.

hackebrot avatar hackebrot commented on June 1, 2024 1

Okay, cool. πŸ™‡

I've used jinja2 assignments to help with that, but as you say, it doesn't work across multiple files.

Thanks for the feedback, I'll take it into consideration when we design a plugin system.

from cookiecutter.

bkonkle avatar bkonkle commented on June 1, 2024

You mention Danny's secret key plugin, but it appears the plugin itself is a secret? :-) I'd love to see it - secret key generation (and other similar extensions) would be quite nice.

from cookiecutter.

theladyjaye avatar theladyjaye commented on June 1, 2024

Is anyone opposed to setuptools entry points for handling this?

I'm going to assume the most natural place to something like this is for users to write their own Jinja2 Extensions so the custom tags can be used in their templating.

At first glance it doesn't seem too difficult to implement, I'd be happy to give it a go. Would pretty much just need to load everything in generate_files and set the extensions=[...] in the Jinja Environment initialization.

The other problem is Jinja Extensions are not exactly straight forward if you haven't done them before. Maybe start off with just simple Jinja Extenions, and then slowly over time add some CC helpers to make authoring them a little more straight forward in common cases?

from cookiecutter.

theladyjaye avatar theladyjaye commented on June 1, 2024

See Pull Request #103

from cookiecutter.

hackebrot avatar hackebrot commented on June 1, 2024

Hi @brettcannon! πŸ‘‹

Would your "own items and plugins" have any dependencies (other than what is already required by cookiecutter itself)?

from cookiecutter.

brettcannon avatar brettcannon commented on June 1, 2024

Nope. Honestly I just want a way to add more items programmatically after the user has entered their info.

To put this in concrete terms, I'm doing {{ cookiecutter.python_version|replace('.', '')|truncate(2, end='') }} across two files in multiple places (setting a variable when I can, but I'm still doing it multiple files), so I would rather do that manipulation in my pre-hook in Python code and store the result in the cookiecutter object so I could then access it from the Jinja code. So no dependencies at all since it's just straight-forward string manipulation that would be easier in Python than Jinja.

from cookiecutter.

hackebrot avatar hackebrot commented on June 1, 2024

I think this falls under the same category as #848. Assigning the Requires Sponsorship label until we have sponsorship for this project.

from cookiecutter.

kurtmckee avatar kurtmckee commented on June 1, 2024

@jensens @pydanny @ssbarnea This issue is 10 years old. I recommend closing the issue.

from cookiecutter.

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.