-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
20 lines (13 loc) · 774 Bytes
/
test.js
File metadata and controls
20 lines (13 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
const { fmt, html, FormattedString } = require('./index.js');
console.log(html`HTML test & hack <b>${'hack & <i>hack</i></b> hack'}</b>` === 'HTML test & hack <b>hack & <i>hack</i></b> hack</b>');
console.log(fmt`Te${['st', 'bold']}`.substring(1, 2));
console.log(fmt`Lorem ${['ipsum', { type: 'italic' }]}`.concat(fmt`test`));
console.log(fmt`Lorem ${['ipsum', 'bold']}`);
const users = [{ firstName: 'A', lastName: 'B', website: 'https://google.com/' }, { firstName: 'C', lastName: 'D' }];
const formatted = fmt`Участники:\n\n${
FormattedString.join(users.map(user => fmt`${[
fmt`${[user.firstName, 'bold']} ${user.lastName}`,
user.website && { type: 'text_link', url: user.website }
]}`), '\n')
}`
console.log(formatted);