https://github.com/ember-cli/ember-cli-preprocess-registry
https://github.com/ember-cli/ember-cli-preprocess-registry
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/ember-cli/ember-cli-preprocess-registry
- Owner: ember-cli
- License: mit
- Created: 2015-06-30T16:02:09.000Z (over 10 years ago)
- Default Branch: main
- Last Pushed: 2023-07-11T23:12:16.000Z (over 2 years ago)
- Last Synced: 2025-06-14T04:37:41.064Z (8 months ago)
- Language: JavaScript
- Size: 372 KB
- Stars: 1
- Watchers: 7
- Forks: 13
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# ember-cli-preprocessor-registry
Used by Ember CLI to provide a registry of preprocessors. The main types
used throughout the system are `css`, `template`, `js`.
## Addon Usage
You can access both your own addon's and your parent's (whichever item is including you)
registry via the `setupPreprocessorRegistry` hook in your addon's `index.js`.
Example:
```js
module.exports = {
name: 'special-js-sauce',
setupPreprocessorRegistry(type, registry) {
if (type !== 'parent') { return; }
registry.add('js', {
name: 'special-js-sauce-preprocessor',
toTree() {
// do your thing here....
}
});
}
}
```
## API
### `Registry.prototype.add(type: String, plugin: Plugin)`
Adds the provided plugin to the registry for the type specified.
Example:
```js
class SpecialSauce {
get name() { return 'special-sauce'; }
toTree(tree) {
// return new tree after processing
}
}
registry.add('js', new SpecialSauce);
```
### `Registry.prototype.load(type: String): Plugin[]`
Returns an array of all plugins that are registered for a given type.
### `Registry.prototype.extensionsForType(type: String): string[]`
Returns an array of all known extensions for a given type.
### `Registry.prototype.remove(type: String, plugin: Plugin)`
Removes the provided plugin from the specified type listing.
## Running Tests
```bash
npm install
npm test
```