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

Add for=, if=, when=, cond=, and case= #93

Merged
merged 3 commits into from Mar 28, 2016
Merged

Add for=, if=, when=, cond=, and case= #93

merged 3 commits into from Mar 28, 2016

Conversation

micha
Copy link
Contributor

@micha micha commented Mar 24, 2016

Is it good?

@livtanong
Copy link
Member

Omg @micha I didn't know delay was a thing!!! Now I need to use it on all the things!

@livtanong
Copy link
Member

@micha do you think it's possible to implement some of the appendChild stuff on a Delay object? That would allow us to do

(cell= (if pred? (delay consequent) (delay alt)))

@micha
Copy link
Contributor Author

micha commented Mar 24, 2016

@levitanong I think you'd still need to create the Delay objects outside the cell, otherwise it would create new ones each time the formula is evaluated, no?

@livtanong
Copy link
Member

@micha Oh right! Silly me. 😄 In that case, I think the if= implementation is definitely cleaner and better than the if-tpl one. +1!

@dm3
Copy link
Contributor

dm3 commented Mar 28, 2016

Should we then remove if-tpl and switch-tpl that got merged into master earlier with this PR then?

    (if-tpl (cell= (= cell1 100))
      (div "one")
      (div "two"))

    (ul
      (for-tpl [x xs]
        (li :text x)))

    (when-tpl cell3?
      (div "one"))

    (cond-tpl
      (cell= (= 100 cell1)) (div "one")
      (cell= (= 200 cell1)) (div "two"))

    (case-tpl cell4
      :foo (div "one")
      :bar (div "two")
      (div "default"))

Note: case-tpl differs from clojure.core/case in that the default case
is optional--the value is nil if no case macthes and there is no default
case (no exception is thrown).
@micha micha merged commit d93a106 into master Mar 28, 2016
@micha micha deleted the tpl-macros branch March 28, 2016 15:53
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.

None yet

3 participants