Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jakehamilton/render-in-place
🎞 Render and overwrite a file
https://github.com/jakehamilton/render-in-place
Last synced: about 5 hours ago
JSON representation
🎞 Render and overwrite a file
- Host: GitHub
- URL: https://github.com/jakehamilton/render-in-place
- Owner: jakehamilton
- Created: 2018-06-15T21:33:08.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-07-06T21:21:42.000Z (over 6 years ago)
- Last Synced: 2024-10-07T01:04:07.178Z (about 1 month ago)
- Language: TypeScript
- Homepage: https://npmjs.com/package/render-in-place
- Size: 102 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 🎞 render-in-place
Render an [ejs](https://npmjs.com/package/ejs) templated file, overwriting it with the result.
# Usage
## Import
This module exposes a function as its `default` export.
### CommonJS
```javascript
const render = require('render-in-place').default;render(...)
```### TypeScript
With `allowSyntheticDefaultImports`
```typescript
import render from 'render-in-place';render(...)
```Without `allowSyntheticDefaultImports`
```typescript
import { default as render } from 'render-in-place';render(...)
// or
import * as rip from 'render-in-place';
rip.render(...)
```## Example
```typescript
import render from 'render-in-place';render(
'/path/to/template', // path to template file
{ data: { to: 'render' } }, // data passed to template
{
read: {}, // config passed to ejs reading file
write: {}, // config passed to fs when writing file
},
)
```# Documentation
## `render(path: string, data: object, config: object)`
### `path`
The absolute path to your template file.
### `data`
Any data to pass off to the template when rendering. This
value is provided directly to `ejs` when rendering your file.### `config`
Extra configuration provided to `ejs.renderFile` or
`fs.writeFile`.#### `config.read`
Configuration passed to `ejs.renderFile`.
#### `config.write`
Configuration passed to `fs.writeFile`.