Created
June 5, 2015 01:59
-
-
Save onetom/43e4009dd8fa124ce399 to your computer and use it in GitHub Desktop.
Function within `cell-let` fails with Hoplon6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defelem cell-let-problem [{:keys [data]}] | |
(cell-let [{:keys [title]} data | |
fun #(str title " - " title) | |
double-title (fun)] | |
(div :text double-title))) | |
(cell-let-problem :data (cell {:title "cell-let test"})) | |
# Uncaught TypeError: fun.call is not a function |
(defelem cell-let-problem [{:keys [data]}]
(cell-let [{:keys [title]} data]
(div (text "~{title} - ~{title}"))))
(cell-let-problem :data (cell {:title "cell-let test"}))
(defelem cell-let-problem [{:keys [data]}]
(cell-let [{:keys [title]} data]
(div :text (cell= (str title " - " title)))))
(cell-let-problem :data (cell {:title "cell-let test"}))
(defelem app-profile [{:keys [app] :as attrs}]
(cell-let
[
{:keys [price categories version release-date languages brand currency platform]} app
apple? (= "apple" platform)
format-values #(-> %
(assoc :price (as-currency currency price))
(assoc :categories (as-tags categories))
(assoc :version (as-str version))
(assoc :brand (as-str brand))
(assoc :release-date (as-date release-date))
(assoc :languages (as-tags languages)))
fields-to-show (concat
[:price :categories :version]
(when apple? [:release-date :languages])
[:brand])
select-fields-to-show #(select-keys % fields-to-show)
field-name
{
:price "Price"
:categories "Categories"
:version "Version"
:release-date "Release date"
:languages "Languages"
:brand "Brand"}
label-fields #(zipmap (map field-name (keys %)) (vals %))
app-summary (-> app format-values select-fields-to-show label-fields)
store-badge (if apple? "/images/apple-store.png" "/images/google-play.png")
]
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This works indeed, but it would be great to save on those (cell= ...)s