Variables don't work in template strings
See original GitHub issueWhen you use a template in your tagged template string css, the browserify transform breaks.
var aColor = '#fff'
var css = sf`.some-class {
background-color: ${aColor};
}`
CssSyntaxError: /Users/bret/repos/hyperamp/renderer/index.js:3:2: Unknown word while parsing file: /Users/bret/repos/hyperamp/renderer/index.js
1 | .some-class {
2 | background-color: ,;
> 3 | }[object Object]
| ^
I started down the road of correcting the in-node implementation, but we are going to have to statically analyze the template string during the transform somehow. I’m not too familiar with this kind of thing. Any ideas?
https://github.com/bcomnes/sheetify/commit/112d7b77448da8f7d73bdbf9bba52171ecab329b
This is related to https://github.com/stackcss/sheetify/issues/54 but specific to the way template variables are busted right now vs how :host
gets used.
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
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 >template strings not working [duplicate] - Stack Overflow
All that is inside a string, is literal. You're writing the variable ${name} inside the normal quotes, so it will be printed literal....
Read more >Template Literals Not Working - Medium
If you are using JavaScript's new template literal syntax in a JSP page it might not work as expected. That's because JSP and...
Read more >Understanding Template Literals in JavaScript - DigitalOcean
Template literals are a new form of making strings… ... Entire expressions can be interpolated, not just variables, such as in this example ......
Read more >Template Strings - TypeScript Deep Dive - Gitbook
Another common use case is when you want to generate some string out of some static strings + some variables. For this you...
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
Should be fixed in
6.0.1
which has the lateststatic-eval
- holler if something’s not working as expectedi wrote my thoughts on sheetify static evaluation in https://github.com/stackcss/sheetify/issues/54#issuecomment-247816150. meanwhile support for template strings has been merged into
static-eval
: https://github.com/substack/static-eval/pull/13. 🍍