Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify phases usage in templates {{ phases.PHASENAME.PHASEVALUE }} true or false #98

Open
benabraham opened this Issue Mar 27, 2019 · 8 comments

Comments

Projects
None yet
3 participants
@benabraham
Copy link
Member

benabraham commented Mar 27, 2019

{{ phases.PHASENAME.PHASEVALUE }} should return True if it's current phasevalue.

In all other cases (not current, non existent, not active) False should be ok.

@benabraham benabraham changed the title Simplify phases usage in templates `{{ phases..PHASENAME.PHASEVALUE }}` true or false Simplify phases usage in templates {{ phases.PHASENAME.PHASEVALUE }} true or false Mar 27, 2019

@encukou

This comment has been minimized.

Copy link
Member

encukou commented Mar 27, 2019

@benabraham

This comment has been minimized.

Copy link
Member Author

benabraham commented Mar 27, 2019

There is probably nothing that can't be done with it as it is now. I'd keep {{ phases.PHASENAME }} and add the simpler boolean which might make more complex comparisons in templates shorter.

Again, just saving an idea for later. No need to worry about this now.

@encukou

This comment has been minimized.

Copy link
Member

encukou commented Mar 27, 2019

But if {{phases.PHASENAME == 'PHASEVALUE'}} works, that means phases.PHASENAME is a string – not a container of PHASEVALUEs, as {{ phases.PHASENAME.PHASEVALUE }} would suggest.

@benabraham

This comment has been minimized.

Copy link
Member Author

benabraham commented Mar 27, 2019

Can't it be both? The string is a string representation of phase object and values are properties?

My PyFu is weak here though…

@encukou

This comment has been minimized.

Copy link
Member

encukou commented Mar 27, 2019

== does not compare string representations.

There is a way to override what == does, but I'd rather avoid that as it's too magic.

@starenka

This comment has been minimized.

Copy link
Contributor

starenka commented Mar 27, 2019

@starenka

This comment has been minimized.

Copy link
Contributor

starenka commented Mar 27, 2019

@benabraham

This comment has been minimized.

Copy link
Member Author

benabraham commented Mar 27, 2019

I guess == works differently in django templates?

@starenka I'm not even sure you're talking about the same thing.

This issue is that instead of writing
{% if phases.PHASENAME == 'PHASEVALUE' %}
it would be possible to do this with same result, nothing more, nothing less
{% if phases.PHASENAME.PHASEVALUE %}

(and I agree it might not be a good idea to do it after all)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.