Skip to content

Commit

Permalink
Update slide.md
Browse files Browse the repository at this point in the history
  • Loading branch information
hax committed Feb 7, 2024
1 parent 7788004 commit 9608683
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions 2024/raw-string/slide.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ console.log(String.raw`
`)
```

But, `` ` ``
But, `

```javascript
let query = `
Expand Down Expand Up @@ -66,7 +66,7 @@ let generatedCode = `
`
```

Not only `` ` ``
Not only `
But also `${`

```javascript
Expand Down Expand Up @@ -103,7 +103,6 @@ you would output the advice:
## Advice
It's more readable to use template literal to replace
the string concatenation.
## Original code
\`\`\`js
let s1 = "This is a\\n"
Expand All @@ -112,7 +111,6 @@ let s1 = "This is a\\n"
let a = 1, b = 2
let s2 = "a + b = " + (a + b)
\`\`\`
## Improved code
\`\`\`js
let s1 = String.dedent\`
Expand All @@ -135,12 +133,14 @@ Use External File?

## Motivation

JS lacks raw literal that can contain any arbitrary text
Prevents containing other languages (eg. JS itself) and text formats (eg. Markdown)
JS lacks raw literal that can
contain any arbitrary text
Prevents containing other languages (eg.
JS itself) and text formats (eg. Markdown)

## Core Goals

1. Raw literal allow *all* string values without escape
1. *All* string values without escape
2. Support interpolations
3. Support tag functions

Expand All @@ -157,15 +157,15 @@ Prevents containing other languages (eg. JS itself) and text formats (eg. Markdo
- here document
- Swift/Rust style

```swift
```js
let query = #`
select *
from `users`
where `name` = ?
`#
```

```swift
```js
let name = "hax"
let generatedCode = #`
let name = $#{JSON.stringify(name)}
Expand Down

0 comments on commit 9608683

Please sign in to comment.