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

Feature Request: Vector concatentation special form #396

Closed
benzap opened this issue Aug 29, 2018 · 1 comment
Closed

Feature Request: Vector concatentation special form #396

benzap opened this issue Aug 29, 2018 · 1 comment

Comments

@benzap
Copy link

benzap commented Aug 29, 2018

When working with a similar library rum, the hiccup-style vector is forgiving when having a nested vector, and will concatenate the first-depth of the nested vector

ex.

;; ....
[:div
  [:div "first element"]
  [[:div "second element"] [:div "third element"]]] ;; note the nested elements in the vector

;; before being rendered, the structure takes the form of:
[:div
 [:div "first element"]
 [:div "second element"]
 [:div "third element"]

This improves the expressiveness when constructing forms by allowing multiple forms to be included in a conditional form

;; ....
[:div
 [:div "some element"]
 (if truthy-stmt
     [[:div "true"] [:div "foo"]] ;; note that the two elements are wrapped in a vector
     [[:div "false"] [:div "bar"]])]

;; before being rendered, the structure takes the form of either
;; truthy
[:div
 [:div "some element"]
 [:div "true"]
 [:div "foo"]]

;; falsy
[:div
 [:div "some element"]
 [:div "false"]
 [:div "bar"]]

Alternatively, an explicit concatentation keyword could be introduced to express intent:

;; ....
[:div
  [:div "first element"]
  [:& ;; note the use of `:& to represent concatenation
   [:div "second element"]
   [:div "third element"]]]

;; when rendered:
[:div
 [:div "first element"]
 [:div "second element"]
 [:div "third element"]

I feel like this functionality can be a great way to improve many situations where multiple forms need to be concatenated, and remove unnecessary :div wrappers that lead to difficult css styling issues that are imposed when working with nested DIVs.

Please consider my enhancement, thank you,

Ben. Z

@benzap
Copy link
Author

benzap commented Aug 29, 2018

This is apparently very similar to React Fragments #319 which was already merged #352, and has been available since Reagent 0.8.0

Closing since this feature already exists in the form:

[:div
  [:div "first element"]
  [:<>
   [:div "second element"]
   [:div "third element"]]]

@benzap benzap closed this as completed Aug 29, 2018
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

No branches or pull requests

1 participant