• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# qw
2
3Quoted word literals!
4
5```js
6const qw = require('qw')
7
8const myword = qw` this is
9  a long list
10  of words`
11// equiv of:
12const myword = [ 'this', 'is', 'a', 'long', 'list', 'of', 'words' ]
13```
14
15You can embed vars in the usual way:
16
17```js
18const mywords = qw`product ${23 * 5} also ${'escaping a string'}`
19// equiv of:
20const mywords = [ 'product', 23 * 5, 'also', 'escaping a string' ]
21```
22
23You can also embed vars inside strings:
24
25```js
26const mywords = qw`product=${23 * 5} also "${'escaping a string'}"`
27// equiv of:
28const mywords = [ 'product=' + (23 * 5), 'also', '"escaping a string"' ]
29```
30
31## DESCRIPTION
32
33This uses template strings to bring over this little common convenience from
34Perl-land.
35
36