Comments (12)
Nitpicking: #i
is a bit ambiguous, what about #str
?
from squint.
Yes, #i
isn't a good choice. Not sure about #str
, maybe too general?. What about #<<
? <<
was the string interpolation macro in clojure.contrib. Too cryptic?
#<< "hello ${name}"
from squint.
Or #$ "hello ${name}
: too Perly...
from squint.
Outside of the reader tag we use, how ought we to handle custom tag functions? Something that would expand to
html`<div style="color: red;">hello ${user}!</div>`
from squint.
perhaps we could allow passing in a list, like #tmpl (html "<div style=\"color: red;\">hello ${user}!</div>")
from squint.
maybe #` ? Some way to indicate that these are backticks?
from squint.
oh dang that's not bad @lilactown, I like it
from squint.
how does that generalize to bare template strings, though?
from squint.
i'm a bit ignorant of how the reader works is but i think we could have it support both bare strings as well as lists with a tag function
#tmpl "Hello, ${user}!"
#tmpl (html "<div style=\"color: red;\">hello ${user}!</div>")
I'm using tmpl
as a stand in for whatever we decide to use.
from squint.
Thinking out loud, I'm worried about how we'll handle complex cases than just interpolating a variable. For instance, how should we handle expressions?
#tmpl "Hello, ${(:name user)}!"
Perhaps we should lean into the tag accepting a collection, and instead of writing the ${}
syntax directly we write lists
#tmpl ("Hello, " user-name "!")
#tmpl ("Hello, " (:name user) "!")
#tmpl (html "<div style=\"color: red;\">Hello, " user-name "!</div>")
from squint.
#tmpl ("Hello, " user-name "!")
Hmm, this isn't any better to me than just using str
. The point of "${foo}"
is that it's easier to write.
We could support #tmpl "Hello ${name}"
and #tmpl [:html "<pre>${name}</pre>]
.
from squint.
@borkdude how should we handle arbitrary expressions inside of the template string, like I was talking about above?
from squint.
Related Issues (20)
- Improvement: use arrow functions instead of "function" for implicit iife
- optimize function definitions for esbuild HOT 6
- `squint/core` Shuffle function suggestions HOT 2
- `squint/core` Prefer slice over pop HOT 4
- cljs is not defined when using `case` HOT 3
- Squint remove ":" for keyword value HOT 16
- class definitions not showing in repl HOT 14
- `nil` keys in map HOT 3
- zipmaps are disordered HOT 3
- `nil` causes a crash in html rendering HOT 1
- html renderer crashes when rendering nil from variable
- How to emit try catch? HOT 3
- REPL fails with `(extends class-1)` in defclass HOT 10
- `html` spread `nil` HOT 1
- Support `js$console` for requiring global libs
- (:query req) or (get req :query) not working on express request object
- could squint be used as a clojurescript compiler to javascript, output of which works with Scittle? HOT 3
- Macros get resolved as normal functions HOT 1
- HTML is not escaped in dynamic expression
- logical not is not working
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from squint.