carltongibson / django-template-partials

Reusable named inline partials for the Django Template Language.
MIT License
387 stars 15 forks source link

startpartial / endpartial does not follow convention according to PyCharm #12

Closed jmuncaster closed 9 months ago

jmuncaster commented 1 year ago

CleanShot 2023-07-26 at 10 58 11@2x

Would it make more sense to define a partial with {% partial %} / {% endpartial %} to be consistent with other blocks?

And include the partial with something like {% include-partial %}?

I know it's a big deal to request a change of keywords, but it seems this would at least be consistent with what one IDE is expecting. Indeed, {% if %} / {% endif %} and {% block %} / {% endblock %} work this way. Or perhaps a user option to choose the start/end tags?

carltongibson commented 1 year ago

Hi @jmuncaster โ€”ย Yes. Hmm. ๐Ÿค”

Grrr. I liked the syntax, so my initial reaction is along the lines of not my problem โ€”ย but OK, let's think about it ๐Ÿ˜…

And include the partial with something like {% include-partial %}?

That really turns me off. Can we come up with something better? (Maybe for the block tag pair? ๐Ÿค”) Naming as ever.

PyCharm's behaviour doesn't happen to be tweak-able does it?

carltongibson commented 1 year ago

Maybe partialdef and endpartialdef would be OK?

Any other ideas?

jmuncaster commented 1 year ago

Totally understand the initial reaction :-)

I couldn't find a way to tweak PyCharm behavior other than to disable the check altogether. But PyCharm aside I don't think startX / endX is idiomatic, at least from what I've seen.

I think partialdef/endpartialdef would be great. I can't think of anything better. I think it is more idiomatic than partial/endpartial and the existing startpartial / endpartial.

scriptogre commented 11 months ago

I just found out about this library from BugBytes, and I was so happy because so far:

I was glad to find this library, which seemed to be exactly what I was looking for.

But I got the same issue as the @jmuncaster . Please do care about us, PyCharm peasants, and try to fix this issue. I've been waiting for this library for almost a year ๐Ÿ˜ฆ

I understand the turn off... But there must be a clean enough approach to make everyone happy. I vouch for:

Define: {% partialdef %} ... {% endpartialdef %}
Use: {% partial %}

Define: {% partialblock %} ... {% endpartialblock %}
Use: {% partial %}

Define: {% partialcontent %} ... {% endpartialcontent %}
Use: {% partial %}

And even this one does not seem SO bad.

Define: {% partial %} ... {% endpartial %}
Use: {% includepartial %}
carltongibson commented 11 months ago

@scriptogre I'm likely to do something here.

I just need a window to get it done. (Life..., but that's a separate topic.)

A PR changing the tags to partialdef, as per the discussion, plus aliasing the existing startpartial, and raising a depreciation warning, would help.

scriptogre commented 10 months ago

Hey Carlton! Sorry for the delay :). Had some life going on as well. Hope this is good enough! Let me know if you find any issues.

carltongibson commented 10 months ago

Hey @scriptogre -- no worries at all, this is the way ๐Ÿ˜…

I had an initial glance. It looks lovely. I'm just occupied elsewhere, and then will be swinging back here to put together an update. ๐Ÿคนโ€โ™€๏ธ

carltongibson commented 9 months ago

Fixed in 4c3c9cdb0984670beab032162856f8cf73fcdde2