Skip to content

Commit 87a228f

Browse files
committed
modernize decorator syntax in the decorator writing docs
1 parent 2b374b1 commit 87a228f

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

docs/0.8/Writing decorator plugins.md.hbs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ A {{{createLink 'decorators' 'decorator'}}} is a way to add behaviour to a node
66

77
For this example we'll create a tooltip decorator. For the impatient, you can see the [finished result in this JSFiddle](http://jsfiddle.net/tomByrer/9g3pB/11/).
88

9-
Firstly, we need to add the `decorator` *directive* to any nodes that the decorator should apply to:
9+
Firstly, we need to add the decorator *directive* to any nodes that the decorator should apply to. You can tell Ractive that an element should be decorated **as** one or more behavior classes:
1010

1111
```html
12-
<p>This text contains <span decorator='tooltip:This is a tooltip'>tooltips</span>.</p>
12+
<p>This text contains <span as-tooltip="'This is a tooltip'">tooltips</span>.</p>
1313
```
1414

1515
(Directives are just instructions to Ractive - they don't actually get added to the element as attributes.)
1616

17-
Now, the `tooltip` decorator function will be called when the `<span>` is added to the DOM. The first argument to the function is the `<span>` itself; subsequent arguments given after the `:` in the directive will be passed to the function - in this case, there will be a second argument, which is the 'This is a tooltip' message.
17+
Now, the `tooltip` decorator function will be called when the `<span>` is added to the DOM. The first argument to the function is the `<span>` itself; arguments given after the `=` in the directive will be passed to the function - in this case, there will be a second argument, which is the 'This is a tooltip' message.
1818

1919
Within that function, we can do whatever we like - the only rule is that it must return an object with a `teardown()` method that gets called if the `<span>` is removed from the DOM. An optional `update()` method can also be returned, which accepts the updated arguments provided to the decorator.
2020

@@ -141,7 +141,7 @@ But wait - what if we don't want to use the `ractive-tooltip` class name? In fac
141141
There are two ways we could address this. Firstly, we could add a whole load of additional arguments to the decorator directive:
142142

143143
```html
144-
<span decorator='tooltip:"This is a tooltip","p","tooltips-ftw",0,-20'>tooltips</span>
144+
<span as-tooltip="'This is a tooltip','p','tooltips-ftw',0,-20">tooltips</span>
145145
```
146146

147147
```js

docs/edge/Writing decorator plugins.md.hbs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ A {{{createLink 'decorators' 'decorator'}}} is a way to add behaviour to a node
66

77
For this example we'll create a tooltip decorator. For the impatient, you can see the [finished result in this JSFiddle](http://jsfiddle.net/tomByrer/9g3pB/11/).
88

9-
Firstly, we need to add the `decorator` *directive* to any nodes that the decorator should apply to:
9+
Firstly, we need to add the decorator *directive* to any nodes that the decorator should apply to. You can tell Ractive that an element should be decorated **as** one or more behavior classes:
1010

1111
```html
12-
<p>This text contains <span decorator='tooltip:This is a tooltip'>tooltips</span>.</p>
12+
<p>This text contains <span as-tooltip="'This is a tooltip'">tooltips</span>.</p>
1313
```
1414

1515
(Directives are just instructions to Ractive - they don't actually get added to the element as attributes.)
1616

17-
Now, the `tooltip` decorator function will be called when the `<span>` is added to the DOM. The first argument to the function is the `<span>` itself; subsequent arguments given after the `:` in the directive will be passed to the function - in this case, there will be a second argument, which is the 'This is a tooltip' message.
17+
Now, the `tooltip` decorator function will be called when the `<span>` is added to the DOM. The first argument to the function is the `<span>` itself; arguments given after the `=` in the directive will be passed to the function - in this case, there will be a second argument, which is the 'This is a tooltip' message.
1818

1919
Within that function, we can do whatever we like - the only rule is that it must return an object with a `teardown()` method that gets called if the `<span>` is removed from the DOM. An optional `update()` method can also be returned, which accepts the updated arguments provided to the decorator.
2020

@@ -141,7 +141,7 @@ But wait - what if we don't want to use the `ractive-tooltip` class name? In fac
141141
There are two ways we could address this. Firstly, we could add a whole load of additional arguments to the decorator directive:
142142

143143
```html
144-
<span decorator='tooltip:"This is a tooltip","p","tooltips-ftw",0,-20'>tooltips</span>
144+
<span as-tooltip="'This is a tooltip','p','tooltips-ftw',0,-20">tooltips</span>
145145
```
146146

147147
```js

0 commit comments

Comments
 (0)