squint

m3tti 2024-07-12T11:34:51.030589Z

how do i use somestring.replace(regex, "_") in squint? My base question is how do i format the regex 😞

borkdude 2024-07-12T12:01:19.594619Z

Hey! Are you aware of how to write a regex in Clojure?

#"foo" 

m3tti 2024-07-12T12:01:43.099689Z

to easy -.-

m3tti 2024-07-12T12:02:16.123229Z

i guess i was confuesed because of using .replace 😄 and thought i have to give it a js notation somehow

m3tti 2024-07-12T12:03:21.612039Z

btw if i have a namespace and require squint compiler on the server side and than do a (let [something ...] the variable created contains the namespace is that correct behaviour? and can i disable it somehow

borkdude 2024-07-12T12:04:03.546319Z

can you give a fuller example?

m3tti 2024-07-12T12:05:13.798789Z

(ns test-tool.js-components
  (:require [squint.compiler :as squint]))

(defn ->js [form]
  (->>
   (squint.compiler/compile-string* (str form))
   :body))

(defn input [value]
  (let [rand-id (str (int (rand 10000)))
        el (->js `)
        cleanup-input (->js `(let [el (js/document.getElementById ~rand-id)]
                               (->
                                el
                                .-value
                                (.replaceAll " " "_")
                                (.toLowerCase)
                                console.log)))]
    [:input {:id rand-id :name "name" :value value :onkeyup cleanup-input}]))

borkdude 2024-07-12T12:06:20.327749Z

This is because ` fully qualified symbols. You can avoid this by using a pound sign:

(->js `(let [el# ...] (-> el# ...))

m3tti 2024-07-12T12:06:34.255909Z

aaaaaaah

m3tti 2024-07-12T12:07:12.620899Z

you are my hero @borkdude

borkdude 2024-07-12T12:07:28.483449Z

:-D

m3tti 2024-07-12T12:07:36.557509Z

this made my day