This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-10-07
Channels
- # beginners (153)
- # cider (2)
- # cljs-dev (1)
- # cljsjs (11)
- # cljsrn (4)
- # clojure (21)
- # clojure-austin (2)
- # clojure-greece (1)
- # clojure-italy (8)
- # clojure-russia (12)
- # clojure-spec (68)
- # clojurescript (35)
- # cursive (4)
- # datomic (2)
- # fulcro (15)
- # off-topic (1)
- # om (1)
- # portkey (35)
- # protorepl (6)
- # re-frame (28)
- # shadow-cljs (13)
- # specter (10)
- # uncomplicate (3)
- # unrepl (7)
Java's String.format() compatible string formatting library for JavaScript. https://github.com/madogiwa/format4js
Or use the format
function from Google Closure library, which has worked great for me.
See answer here — which is where this example comes from:
https://stackoverflow.com/questions/34667532/clojure-clojurescript-e-g-the-format-function
(ns rostering.components.services
(:require
[goog.string :as gstring]
[goog.string.format]))
(str "$" (gstring/format "%.2f" 2.5))
As you’ve probably gathered Bravi - it does not.
Basically, I have this line
[:p (format "Your score is: %d" @score)]
and doesn’t seem to work@bravilogy there is a format
function in Google Closure Library
thank you for tips, @mfikes , a bit of require setup
(:require [goog.string :as gstring]
[goog.string.format]
(gstring/format "Your score is: %d" @score)
goog.string.format has significant dead code elimination issues, I think it was removed from cljs for this reason
Thank you @danielcompton maybe best to go with cuerdas https://funcool.github.io/cuerdas/latest/
You can also use it directly, I misspoke above, cljs.core/format (which used goog.string.format) was removed from core. You can still call goog.string.format yourself
But be aware of DCE issues
True, @danielcompton cuerdas makes use of goog.string but does its own format
I’m having an unusual problem with lein cljsbuild auto
that I’ve not had before. It will automatically compile upon save and show that is Successfully compiled in around 1.X seconds. But this message doesn’t actually appear for about 10 seconds. Anyone else seen this recently with recent versions of the compiler?
Sorry, @bravilogy clojurescript removed format since v0.0-1885 https://cljs.github.io/api/cljs.core/format
@lovuikeng thanks
does it work the same way as node? In a sense that do I need to redirect connections from my nginx server?
Java's String.format() compatible string formatting library for JavaScript. https://github.com/madogiwa/format4js
@bravilogy using lein to create an uberjar... here can follow re-frame-template https://github.com/Day8/re-frame-template
$ lein new re-frame myapp +handler
$ cd myapp
$ lein uberjar
Compiling ClojureScript...
Compiling "resources/public/js/compiled/app.js" from ["src/cljs"]...
...
$ java -jar target/myapp.jar
2017-10-07 19:12:42.805:INFO::main: Logging initialized @2006ms
2017-10-07 19:12:42.855:INFO:oejs.Server:main: jetty-9.2.z-SNAPSHOT
2017-10-07 19:12:44.424:INFO:oejs.ServerConnector:main: Started ServerConnector@
3281dfc2{HTTP/1.1}{0.0.0.0:3000}
2017-10-07 19:12:44.425:INFO:oejs.Server:main: Started @3627ms
https://clojurescript.org/guides/javascript-modules#javascript-modules I can't follow this successfully. I did it all in copy/paste style & got: https://clbin.com/SIIVA am I doing something obviously wrong?
I have a barebones CLJS app, based on the figwheel + reagent template. I've added some :npm-deps
, but I just can't seem to :require
them.
Project: https://github.com/jeaye/re-frame-trace-server/blob/master/project.clj#L36 Require: https://github.com/jeaye/re-frame-trace-server/blob/master/src/re_frame_trace_server/core.cljs#L3
I've followed every CLJS doc I've found regarding bringing in these NPM deps, which, as I gather, I'm meant to be able to require with no issue. Have I missed something?
Or use the format
function from Google Closure library, which has worked great for me.
See answer here — which is where this example comes from:
https://stackoverflow.com/questions/34667532/clojure-clojurescript-e-g-the-format-function
(ns rostering.components.services
(:require
[goog.string :as gstring]
[goog.string.format]))
(str "$" (gstring/format "%.2f" 2.5))