Skip to content

Commit

Permalink
Update readme with render prop example
Browse files Browse the repository at this point in the history
  • Loading branch information
aquibm committed Jan 22, 2020
1 parent a262ffe commit 2aecc01
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 82,35 @@ class Example extends Component {
}
```

## Custom rendering via render prop

You can render however you'd like by passing through a render prop

```jsx
import React, { Component } from 'react'
import { ReactLiquid } from 'react-liquid'

class Example extends Component {
render() {
const template = '<p style="color: tomato;">{{ name }}</p>'
const data = {
name: 'aquibm',
}

return (
<ReactLiquid
template={template}
data={data}
render={renderedTemplate => {
console.log('Woohoo! New Render!')
return <span dangerouslySetInnerHTML={renderedTemplate} />
}}
/>
)
}
}
```

## License

[MIT](LICENSE.md) © Aquib Master

0 comments on commit 2aecc01

Please sign in to comment.