Skip to content

allows for use of inline conditionals in attributes#184

Open
zeraien wants to merge 3 commits intosyrusakbary:masterfrom
zeraien:inline_conditionals
Open

allows for use of inline conditionals in attributes#184
zeraien wants to merge 3 commits intosyrusakbary:masterfrom
zeraien:inline_conditionals

Conversation

@zeraien
Copy link
Copy Markdown

@zeraien zeraien commented Mar 30, 2015

This allows for a ternary ? conditional statement to be used in pyjade attributes.

li(bar=1?'1':'0')
a(foo='foo', bar=1+1==2?'15':'0')
a(bar=1+1==1?'1':'1+1 is not 1')
a(bar=(1+1)==2&&1?'(1+1)==2 and 1':'0')

Or a Django example:

li(role="presentation", class=range['current'] ? "disabled":"")

@auvipy
Copy link
Copy Markdown

auvipy commented Nov 11, 2015

state of the pr?

@frgtn
Copy link
Copy Markdown
Contributor

frgtn commented Nov 11, 2015

You can already use inline python conditionals like so:

a(bar=("foo" if condition else "baz"))

@syrusakbary syrusakbary force-pushed the master branch 3 times, most recently from 4a76e8a to eb84811 Compare January 7, 2016 17:08
@kakulukia
Copy link
Copy Markdown

Since there are no updates to pyjade and its successor recently was deleted from pypi, I took the liberty to revive it: https://github.com/kakulukia/pypugjs

Version 5.0.1 has fixed the incompatibility with recent Django versions.

Like stated above there already is a way of doing what you want and for assigning classes there is another PR open that solves the same problem in a more elegant way. Hope it get resubmitted or else i will probably include it myself to pypugjs since i like it. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants