https://github.com/jsreport/jsreport-fs-store
jsreport template store extension
https://github.com/jsreport/jsreport-fs-store
Last synced: 11 months ago
JSON representation
jsreport template store extension
- Host: GitHub
- URL: https://github.com/jsreport/jsreport-fs-store
- Owner: jsreport
- Created: 2015-10-17T12:22:30.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2021-08-20T16:38:07.000Z (almost 5 years ago)
- Last Synced: 2025-06-22T14:03:49.428Z (12 months ago)
- Language: JavaScript
- Size: 1.46 MB
- Stars: 4
- Watchers: 5
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
**⚠️ This repository has been moved to the monorepo [jsreport/jsreport](https://github.com/jsreport/jsreport)**
--
# jsreport-fs-store
[](https://npmjs.com/package/jsreport-fs-store)
[](https://travis-ci.com/jsreport/jsreport-fs-store)
**[jsreport](https://github.com/jsreport/jsreport) template store extension. Supports editing templates in the external editors and browsers live reload and preview!**
See the docs https://jsreport.net/learn/fs-store
## Installation
> npm install jsreport-fs-store
Then alter jsreport configuration
```js
{
'store': { 'provider': 'fs' }
}
```
## Development
(This section is intended to jsreport extension developers audience.)
### Entity definitions
Use `splitIntoDirectories` attribute in `registerEntitySet` to use the directory structure for storing. Otherwise the storage will put every entity row into the one single file.
```js
this.documentStore.registerEntitySet("templates", {entityType: "jsreport.TemplateType", splitIntoDirectories: true});
```
Not every jsreport entity should be spitted into the tree structure. It is especially not desired for the entities where you expect thousands of entries. In this case just remove the `splitIntoDirectories` attribute.
The second required step is to extend the entity type with `publicKey` which is marking the attribute used for the row directory name. And also adding the `document` for the attributes you want to extract into dedicated files.
```js
var templateAttributes = {
...
shortid: {type: "Edm.String"},
name: {type: "Edm.String", publicKey: true},
content: {type: "Edm.String",
document: { extension: "html", engine: true }
}
...
};
```
### Engines
Engines like handlebars or jade are able to override the default file extension for the template content files. This can be done using file extension resolver....
```js
reporter.documentStore.addFileExtensionResolver(function(doc, entitySetName, entityType, propertyType) {
if (doc.engine === "handlebars" && propertyType.document.engine) {
return "handlebars";
};
});
```