Back
ffmt (clj)
(source)macro
(ffmt s & params)
Alternative (to `istr`) string formating macro, that performs simple
string formating on the compile time (this means that the string
should be known at compile time). Internally it uses the fast string
concatenation mechanism implemented in the `concat` macro.
If you don't need the peculiarities of the `istr` macro, this macro
should be prefered.
It works with two basic forms: sequencial and indexed. Let seen an
example:
(str/ffmt "url(%)" my-url) ; sequential
(str/ffmt "url(%1)" my-url) ; indexed
Examples
penpot/penpot
#_:clj-kondo/ignore
(ns app.common.data.macros
"Data retrieval & manipulation specific macros."
(:refer-clojure :exclude [get-in select-keys str with-open min max])
#?(:cljs (:require-macros [app.common.data.macros]))
(:require
#?(:clj [clojure.core :as c]
:cljs [cljs.core :as c])
[app.common.data :as d]
[cljs.analyzer.api :as aapi]
[cuerdas.core :as str]))
(dm/fmt \"url(%)\" my-url) ; sequential
(dm/fmt \"url(%1)\" my-url) ; indexed
"
[s & params]
`(str/ffmt ~s ~@params))
(defmacro assert!
([expr]
`(assert! nil ~expr))
([hint expr]
(let [hint (cond
(vector? hint)
`(str/ffmt ~@hint)
(defmacro verify!
([expr]
`(verify! nil ~expr))
([hint expr]
(let [hint (cond
(vector? hint)
`(str/ffmt ~@hint)
penpot/penpot
(ns app.main.ui.components.color-bullet
(:require
[app.config :as cfg]
[app.util.color :as uc]
[app.util.dom :as dom]
[app.util.i18n :as i18n :refer [tr]]
[cuerdas.core :as str]
[rumext.v2 :as mf]))
(:image color)
(let [uri (cfg/resolve-file-media (:image color))]
[:div.color-bullet-wrapper {:style {:background-size "contain" :background-image (str/ffmt "url(%)" uri)}}])
penpot/penpot
(ns app.main.ui.components.color-bullet-new
(:require-macros [app.main.style :as stl])
(:require
[app.config :as cfg]
[app.util.color :as uc]
[app.util.i18n :as i18n :refer [tr]]
[cuerdas.core :as str]
[rumext.v2 :as mf]))
(some? image)
(let [uri (cfg/resolve-file-media image)]
[:div {:class (stl/css :color-bullet-wrapper)
:style {:background-image (str/ffmt "url(%)" uri)}}])