Skip to content

Commit

Permalink
Add advanced formatting docs
Browse files Browse the repository at this point in the history
  • Loading branch information
bearfriend committed Aug 23, 2024
1 parent cfb640f commit c6399a6
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -340,15 +340,31 @@ Similarly `<em>` *emphasizes* a particular piece of text (browsers show this vis

Example:

```json
```javascript
{
myMessage: "This is <b>bold</b> but <em>not</em> all that <strong>important</strong>."
}
```

#### Advanced Formatting

More advanced formatting can be achieved by providing replacement methods for custom tags, which are similar to arguments:

```javascript
{
"myMessage": "This is <b>bold</b> but <em>not</em> all that <strong>important</strong>."
goHome: "Go <homeLink>home</homeLink>"
}
```

```javascript
localizer.localizeHTML('myMessage');
localizer.localizeHTML('goHome', {
homeLink: chunks => `<d2l-link href="/home">${chunks}</d2l-link>`
});
```
In addition to the Basic Formatting elements, these additional elements may also be used in replacement methods:

* `<d2l-link>`
* `<d2l-tooltip-help>`

### `onResourcesChange`
Provide an `onResourcesChange` callback function to perform tasks when the document language is changed and updated resources are available:
Expand Down

0 comments on commit c6399a6

Please sign in to comment.