This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-09-05
Channels
- # asami (13)
- # aws (7)
- # babashka (4)
- # beginners (16)
- # biff (7)
- # cljdoc (10)
- # clojure (32)
- # clojure-europe (27)
- # clojure-nl (14)
- # clojure-norway (7)
- # clojure-uk (3)
- # clojurescript (2)
- # conjure (2)
- # core-async (13)
- # datalevin (4)
- # datomic (3)
- # holy-lambda (7)
- # kaocha (3)
- # lsp (23)
- # off-topic (39)
- # pedestal (10)
- # portal (5)
- # practicalli (2)
- # rdf (10)
- # releases (1)
- # shadow-cljs (66)
- # tools-deps (146)
- # uncomplicate (1)
- # xtdb (10)
Good day,
How can I render each game in its own div
rather than the set of vectors xtdb gives me. e.g go from
#{["game1"]["game2"]["game3"]}
#{["game1"]["game2"]["game3"]}
#{["game1"]["game2"]["game3"]}
to:
game1
game2
game3
(defn list-games [{:keys [biff/db] :as sys}]
(let [games (biff/q db
'{:find [title]
:where [[_ :game/title title]]})]
(ui/page
{}
(for [game games]
[:div.text-green-600 games]))))
;; schema.clj
(def schema
{:game/id :uuid
:game/title :string
:game [:map {:closed true}
[:xt/id :game/id]
almost there--you can change the for
bit to this:
(for [[title] games]
[:div.text-green-600 title])
Hello, How are new features implemented in Biff? If add the following handler to an existing feature it works fine, but I get a 404 when it's implemented as it's own feature (no console error of note). email.clj
(ns com.game.feat.email
(:require [com.biffweb :as biff]
[com.game.ui :as ui]))
(defn email [_]
(ui/page
{}
[:div.flex.items-center.justify-center "Email"]))
(def features
{:routes [["/email" {:get email}]]})
You'll need to add the new feature map to this vector in your app's main namespace: https://github.com/jacobobryant/biff/blob/master/example/src/com/example.clj#L15
Thanks, as an aside how are image paths handled in Biff? if I have the following image:
/game/resources/public/img/email.jpg
What's the correct way to specify it's path?
i.e
(defn email [_]
{}
[:div
[:img {:src "img/email.jpg}]])
the resources/public/
directory (and also target/resources/public
, for generated files) is used as a root for static files (https://github.com/jacobobryant/biff/blob/master/src/com/biffweb/impl/middleware.clj#L42 is the relevant line in Biff's internals). The path you'd use for that file is "/img/email.jpg"
. i.e. add a slash at the beginning so it's an absolute path instead of relative.
Final draft is done: https://biffweb.com/p/updates-2022-08/ I'm also trying out using Github Discussions for blog comments: https://github.com/jacobobryant/biff/discussions/133