Support for negative conditional tokens #385
bschrag620
started this conversation in
Ideas
Replies: 1 comment 2 replies
-
I really like this idea. Perhaps we could use a div(
class: tokens(
active?: { then: "active", else: "inactive" }
)
) The The idea of using the method’s return value as a COLORS = {...}
SIZES = {...}
STYLES = {...}
div(
class: tokens(COLORS[@color], STYLES[@style], SIZES[@size])
) Or inline div(
class: tokens(
{
a: "foo",
b: "bar"
}[style]
)
)
def style = :a |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I really like the
tokens
andclasses
helpers. One thing I ran into is there are cases where under the true condition I need a token added, and under a false condition I need a different token added. Currently that might look something like this:The idea would be to utilize an array to hold the opposite value. I realize arrays are already a supported conditional token value so it would mean not supporting an array as a value for conditional tokens or allowing nested arrays to support the negative case:
I think there is an argument to be made about supporting a hash token where the return value from the conditional check is used as a lookup in the hash:
The refactor that lives in my head would involve creating a
Phlex::TokenGenerator
class, whichtoken
would instantiate.Beta Was this translation helpful? Give feedback.
All reactions