Data
Files in data directory specified by myst.json are loaded and stored into a single object. The loader can load .json, .yaml and .js files.
Each .js file is executed by require and its return value (i.e. module.exports value) is taken. If the return value is Promise, its resolved value is taken.
Example
If you have following files in data directory:
{
"type": "json",
"吾輩は": "猫である"
}type: yaml
array:
- 長男
- 次男
- 三男module.exports = {
type: 'js',
};Then the result is:
{
"foo": {
"type": "json",
"吾輩は": "猫である"
},
"bar": {
"type": "yaml",
"array": ["長男","次男","三男"]
},
"hoge": {
"type": "js"
}
}and is exposed to templates. Use like this:
<p>{foo.type}</p>Caches
If myst.json has a cache field, whole data will be written into a single JSON file. The cache is used next time to reduce file system access. If you have data that cannot be serialized as a JSON value, you should not use caches.
In the above example, if the cache has the value .myst.cache.json, it will be like:
{
"foo": {
"type": "json",
"吾輩は": "猫である",
"$mtime": 1468751336241
},
"bar": {
"type": "yaml",
"array": ["長男","次男","三男"],
"$mtime": 1468751336241
},
"hoge": {
"type": "js",
"$mtime": 1468751336241
},
"$mtime": 1468751336241
}where $mtime is the last modified time of each file / directory.