-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Description
Intro
Template strings are a way to interpolate variables with strings. It's nice, and often more readable than traditional string concatenation
Tagged template strings take this behavior a bit further, and allow functions to be called as if they were strings - but instead the functions receive multiple strings, and a trailing array of positional arguments that the have been used for interpolation. This allows operating on the string and adding all sorts of interesting behavior.
Example
var css = require('sheetify')
// this is a static expression
`
.js-yellow { color: #f7df1e }
.bg-js-yellow { background-color: #f7df1e }
`
// this is a function call, which in this case has side effects
css`
.js-yellow { color: #f7df1e }
.bg-js-yellow { background-color: #f7df1e }
`Bug
It appears that standard@9 has introduced a regression where tagged template strings are now considered static expressions - even though they're functions. I think we should probably look into this.
❯ standard
standard: Use JavaScript Standard Style (http://standardjs.com)
/Users/anon/src/yoshuawuyts/berlinjs/index.js:14:1: Expected an assignm
ent or function call and instead saw an expression.Thanks!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Type
Projects
Status
Done