This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-07-02
Channels
- # announcements (1)
- # babashka (15)
- # beginners (34)
- # calva (19)
- # clerk (6)
- # clojure (29)
- # clojure-dev (4)
- # clojure-europe (2)
- # clojurescript (2)
- # conjure (1)
- # cursive (56)
- # datomic (4)
- # gratitude (1)
- # hyperfiddle (18)
- # lsp (15)
- # nextjournal (2)
- # off-topic (9)
- # reitit (16)
- # releases (1)
- # slack-help (2)
- # specter (1)
- # tools-deps (12)
- # transit (1)
Selmer users: In a custom tag, any way that I can resolve variables?
(html/add-tag!
:ifendswith
(fn [args _context-map content]
(if (str/ends-with? (first args) (second args))
(-> content :ifendswith :content)
(-> content :else :content)))
:else :endifendswith)
Template:
{% ifendswith {{game.push.img}} "cover_large.jpg" %}
<img src="{{game.igdb.img}}" alt="Cover of {{game.title}}">
{% else %}
<img src="{{game.push.img}}" alt="Cover of {{game.title}}">
{% endifendswith %}
The custome tag gets "{{game.push.img}}" as the arg, but I would want this resolved and get the value it refers too instead.IIRC, my solution to this was to have my tags support @dotted.var.name
and if the first char of the arg was @
, to split the rest and use it to get-in
the context map...
I see, I was worried I'd have to do some parsing of my own. But if there's no built in way, I guess I'll do it.
Hum, that function seems to already exists in Selmer here: https://github.com/yogthos/Selmer/blob/51ce02b1f736486b7733a39c3805e9cc5f969e7d/src/selmer/filter_parser.clj#L75C1-L84C13 It takes a context map, and returns a fn that given a @dotted.var.name resolves the value from the context map.
Ah, so maybe my suggested syntax "just works" without additional parsing now?
I'll have a look when I'm back at work tomorrow...
That's specifically for arguments to filters: foo|date:@format
:
user=> (html/render "{{when|date:@format}}" {:when #inst "2023" :format "shortDate"})
"12/31/22"
user=> (html/render "{{when|date:@format}}" {:when #inst "2023" :format "longDate"})
"December 31, 2022"
user=>
Oh interesting. Well it would be a nice feature if that syntax also worked standard for arguments to tags.
But I ended up finding I can reuse a few functions from the parser and get it to fully resolve variables, but even apply filters, inner tags and all that. https://github.com/yogthos/Selmer/issues/303
Trying to use thread
from core.async in a REPL, but it’s failing with this exception.
Syntax error macroexpanding go at (*cider-repl Clojure/scratch:localhost:62417(clj)*:29:16).
Attempting to call unbound fn: #'clojure.core.async.impl.ioc-macros/state-machine
Here’s the code I am trying to run.
(defn fake-fetch []
(thread
(Thread/sleep 5000)
"Ready!"))
(let [c (fake-fetch)]
(go (println (<! c))))
A quick Google search suggests this is related to AOT compilation, but I don’t have any AOT settings configured in my project.clj
file. Any idea what’s going on?Yeah, definitely wrong.
Also, I now realize that the error in the OP is about the go
macro, so seems like it should error out on your side even with (go (println (<! (to-chan! [1]))))
.
Regarding examples: I referenced clojuredoc and the thread
section in https://www.braveclojure.com/core-async/
Yeah, those work for me just fine without go
. Not sure why state-machine
is unbound in your case.
There was someone else seeing a similar behavior but without core.async
: https://clojurians.slack.com/archives/C03S1L9DN/p1687801725042649?thread_ts=1687459697.547859&cid=C03S1L9DN
Ended up being some dependency somehow messing things up.
Don't think so. I'm using the latest version of core.async together with a bunch of pedestal packages
that is, if you're on latest (1.6.673) try 1.5.648 and see if you're still seeing it
the latest version dynamically loads the ioc-macros only during compilation (not needed at runtime), but you might be seeing some "interesting" load order here, hard to really diagnose without a lot more info
Hopefully the optimization will get rolled back or someone will fork core.async to make it optional.
"Which server-side languages are we using with ClojureScript?" was asked on the State of Clojure 2023 survey. I see the bars, but only half of the labels! Clojure, , Python, , Java, , Go... I am curious what's in 2nd, 4th, and 6th place. The results I refer to are linked to from here: https://clojure.org/news/2023/06/30/state-of-clojure-2023. On my mobile phone, most of the bar graphs are similarly label-sparse, but, back on the desktop, I tried resizing the page and shrinking the print but I still did not see the elided labels.
This was discussed on the other thread and I dropped the full image there. I have a support case open with surveymonkey on this