https://github.com/reshape/eval-code
evaluate all code nodes and transform to text nodes
https://github.com/reshape/eval-code
Last synced: 11 months ago
JSON representation
evaluate all code nodes and transform to text nodes
- Host: GitHub
- URL: https://github.com/reshape/eval-code
- Owner: reshape
- License: other
- Created: 2017-05-02T22:03:40.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2018-04-05T20:05:10.000Z (about 8 years ago)
- Last Synced: 2024-04-14T20:21:31.127Z (about 2 years ago)
- Language: JavaScript
- Size: 53.7 KB
- Stars: 1
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: contributing.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Reshape Eval Code
[](https://npmjs.com/package/reshape-eval-code)
[](https://travis-ci.org/reshape/eval-code?branch=master)
[](https://david-dm.org/reshape/eval-code)
[](https://codecov.io/gh/reshape/eval-code)
Evaluate all code nodes and transform to text nodes
> **Note:** This project is in early development, and versioning is a little different. [Read this](http://markup.im/#q4_cRZ1Q) for more details.
### Installation
`npm install reshape-eval-code -S`
### Usage
If you have your locals and want to resolve them early so that subsequent plugins can use them directly instead of running into `code` nodes, reshape eval code is your friend. It's a very simple plugin, you just feed it your locals and it will go through all code nodes and resolve them, then run whatever they produce through a parse so that even if you produce html with your code nodes it will still come out as a full reshape AST.
```js
const reshape = require('reshape')
const expressions = require('reshape-expressions')
const evalCode = require('reshape-eval-code')
reshape({ plugins: [expressions(), evalCode({ foo: 'bar' })] })
.process('
{{ foo }}
')
.then((res) => {
console.log(res.output()) // no locals required here! nice!
})
```
### License & Contributing
- Details on the license [can be found here](LICENSE.md)
- Details on running tests and contributing [can be found here](contributing.md)