idea: template string interpolation
See original GitHub issueCurious if interpolation for template strings is something of interest? For example:
var red = '#f00'
var cssString = '.upper { text-transform: uppercase }'
var prefix = css`
:host {
background: ${red}
}
${cssString}
`
In Node, doing the interpolation itself isn’t tooo bad if we parse sheetify args and pass into a thing like:
// v simplified for example sake!
function sheetify () {
var args = Array.prototype.slice.apply(arguments)
var css = interpolate(args[0], args.slice(1))
// ...etc
}
function interpolate (strs, vals) {
return strs.map(function (str, i) {
return str + (vals[i] || '')
}).join('')
}
But! It seems like the complication is the browserify transform. Ideally the transform would actually execute the js so the insert-css()
call has no additional overhead. But perhaps a transform like yo-yoify where calls to sheetify w/in the source are converted into plain functions could work too?
I took a look at implementing this today, but I’m quite unfamiliar with writing browserify transforms, and as I was banging head against wall figured I’d stop and check to see if this even falls within the sheetify radar 📡🖖
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Template string interpolation · Issue #623 · emberjs/rfcs - GitHub
This is a good idea, but it doesn't seem like anyone actually wants to write the RFC. Is there anything we can do...
Read more >String Interpolation for Apex | IdeaExchange - Salesforce
The ability to have line breaks within the template. I feel very burdened when writing tests for my Apex REST methods, which invariably...
Read more >Code analysis and helpers for string literals - ReSharper
ReSharper analyzes format strings and arguments of all .NET string formatting methods, such as String.Format , Text.StringBuilder.
Read more >Idea: String interpolation in i18n API - Temenos Basecamp
A good example of how this should work is Javascript's concept of Template Strings using named variable substitutions in a ${var_name} notation, ...
Read more >Template literals (Template strings) - JavaScript | MDN
Template literals are literals delimited with backtick (`) characters, allowing for multi-line strings, string interpolation with embedded ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Woot! Yeah, think this good to close (:
On Wed, Sep 20, 2017 at 12:18 AM Jon Gacnik notifications@github.com wrote:
Hey all @ahdinosaur @yoshuawuyts ! Jumping back in here since #134 pretty much solves this for us! This added support to require node modules via the transform, something like:
style.js
app.js
wonder if we should call this closed 🤔 ?