Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Jinja2 template support #197

ShaheedHaque started this conversation in General
Discussion options

I understand that the current way reactpy-django integrates with Django is based on Django's native templates. Is there any prospect of integration with Django's alternative Jinja2-templates?

You must be logged in to vote

Replies: 4 comments 1 reply

Comment options

To be honest I've never used Jinja2 within Django. However, I'm open to the idea of it.

It would be really easy to replicate our current template tag with jinja2-simple-tags. Or alternatively, if Django has some built-in system for Jinja2, we could utilize that.

Would you be interested in creating a PR for this?

You must be logged in to vote
0 replies
Comment options

Yes I would. I do have some experience of creating custom Jinja2 tags, but my knowledge on the JS side is pretty scant (I use vanilla ES6 JS. but nothing like a transpiler, tree-shaking or framework such as React. For me, I'd need to use the experience to learn how the rest of the world does JS ;-)).

I'll get back in touch when I have something.

You must be logged in to vote
1 reply
Comment options

A PR adding Jinja2 support would not involve any JS. All of our JavaScript code already exists, and should not be modified for this.

The two following things would need to be accomplished/confirmed:

  1. Make sure our existing HTML template can render with Jinja2.
    • Either create a ./templates/component-jinja2.html template or figure out some way to make the existing template work for both Jinja2 and Django interchangeably.
    • Here's a workaround for the static tag that could be useful?
  2. Make sure the existing Django Template Tag works with Jinja2.
    • I've always assumed that Django template tags somehow automagically work with Jinja2.
Comment options

A PR adding Jinja2 support would not involve any JS. All of our JavaScript code already exists, and should not be modified for this.

Ack. I was more thinking of what I'd need to learn to test the new template!

The two following things would need to be accomplished/confirmed:

Thanks for the pointers. Luckily I've some experience creating Jinja2 tags (I contributed the existing "debug" tag) and am not expecting problems with that bit.

You must be logged in to vote
0 replies
Comment options

See #198

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /