Skip to content

Commit

Permalink
Add extension buffer to registerElement examples (ampproject#21030)
Browse files Browse the repository at this point in the history
* Add AMP.extension buffer to registerElement line.

* Modify building-an-amp-extension.md to include extension buffer when registering an element with AMP.
  • Loading branch information
caroqliu authored and bramanudom committed Mar 22, 2019
1 parent 63480c8 commit 071f6a8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion build-system/tasks/extension-generator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,9 @@ export class ${className} extends AMP.BaseElement {
}
}
AMP.registerElement('${name}', ${className});
AMP.extension('${name}', '0.1', AMP => {
AMP.registerElement('${name}', ${className});
});
`;
}

Expand Down
12 changes: 9 additions & 3 deletions contributing/building-an-amp-extension.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ class AmpMyElement extends AMP.BaseElement {
}
}

AMP.registerElement('amp-my-element', AmpMyElement, CSS);
AMP.extension('amp-my-element', '0.1', AMP => {
AMP.registerElement('amp-my-element', AmpMyElement, CSS);
});
```

### BaseElement callbacks
Expand Down Expand Up @@ -287,7 +289,9 @@ AMP; all AMP extensions are prefixed with `amp-`. This is where you
tell AMP which class to use for this tag name and which CSS to load.

```javascript
AMP.registerElement('amp-carousel', CarouselSelector, CSS);
AMP.extension('amp-carousel', '0.1', AMP => {
AMP.registerElement('amp-carousel', CarouselSelector, CSS);
});
```

## Actions and events
Expand Down Expand Up @@ -694,7 +698,9 @@ Class AmpMyElement extends AMP.BaseElement {
}
}

AMP.registerElement('amp-my-element', AmpMyElement, CSS);
AMP.extension('amp-my-element', '0.1', AMP => {
AMP.registerElement('amp-my-element', AmpMyElement, CSS);
});
```

### Enabling and removing your experiment
Expand Down

0 comments on commit 071f6a8

Please sign in to comment.