An open API service indexing awesome lists of open source software.

https://github.com/mtso/babel-plugin-transform-pipe-operator

Babel plugin to add Angularjs's transform pipe operator.
https://github.com/mtso/babel-plugin-transform-pipe-operator

babel operator pipe plugin

Last synced: 5 months ago
JSON representation

Babel plugin to add Angularjs's transform pipe operator.

Awesome Lists containing this project

README

          

# babel-plugin-transform-pipe-operator

Adds a pipe operator to call pure, synchronous transformer functions within JSX expressions.

## Example

A pipe inside a JSX expression,

```js
const Shout = ({ name }) => (

YO, { name | toUpperCase }!

);
```

Becomes a function call in the result:

```js
const Shout = ({ name }) => (

YO, { toUpperCase(name) }!

);
```

To pass a parameter, implement the transformer as a factory.

```js
const toFixed = (places) => (value) => value.toFixed(places);

const Cell = ({ value }) => (
{ value | toFixed(2) }
);
```

```js
const toFixed = (places) => (value) => value.toFixed(places);

const Cell = ({ value }) => (
{ toFixed(2)(value) }
);
```