Adding a getManifest function to string templates.
This commit is contained in:
parent
9e3d2a3553
commit
d5b8ffe086
|
@ -75,6 +75,7 @@ specifiers so that it is safe for use in Handlebars. Ideally this function shoul
|
||||||
being accessed, for example `[Table 1].[property name]` is the syntax that is required for Handlebars.
|
being accessed, for example `[Table 1].[property name]` is the syntax that is required for Handlebars.
|
||||||
6. `isValid` - `(string)` - checks the given string for any templates and provides a boolean stating whether it is a valid
|
6. `isValid` - `(string)` - checks the given string for any templates and provides a boolean stating whether it is a valid
|
||||||
template.
|
template.
|
||||||
|
7. `getManifest` - returns the manifest JSON which has been generated for the helpers, describing them and their params.
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
This library is built with [Rollup](https://rollupjs.org/guide/en/) as many of the packages built by Budibase are. We have
|
This library is built with [Rollup](https://rollupjs.org/guide/en/) as many of the packages built by Budibase are. We have
|
||||||
|
|
|
@ -3,6 +3,7 @@ const { registerAll } = require("./helpers/index")
|
||||||
const processors = require("./processors")
|
const processors = require("./processors")
|
||||||
const { cloneDeep } = require("lodash/fp")
|
const { cloneDeep } = require("lodash/fp")
|
||||||
const { removeNull, addConstants } = require("./utilities")
|
const { removeNull, addConstants } = require("./utilities")
|
||||||
|
const manifest = require("../manifest.json")
|
||||||
|
|
||||||
const hbsInstance = handlebars.create()
|
const hbsInstance = handlebars.create()
|
||||||
registerAll(hbsInstance)
|
registerAll(hbsInstance)
|
||||||
|
@ -118,3 +119,12 @@ module.exports.isValid = string => {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We have generated a static manifest file from the helpers that this string templating package makes use of.
|
||||||
|
* This manifest provides information about each of the helpers and how it can be used.
|
||||||
|
* @returns The manifest JSON which has been generated from the helpers.
|
||||||
|
*/
|
||||||
|
module.exports.getManifest = () => {
|
||||||
|
return manifest
|
||||||
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ const {
|
||||||
processString,
|
processString,
|
||||||
isValid,
|
isValid,
|
||||||
makePropSafe,
|
makePropSafe,
|
||||||
|
getManifest,
|
||||||
} = require("../src/index")
|
} = require("../src/index")
|
||||||
|
|
||||||
describe("Test that the string processing works correctly", () => {
|
describe("Test that the string processing works correctly", () => {
|
||||||
|
@ -101,3 +102,11 @@ describe("check the utility functions", () => {
|
||||||
expect(property).toEqual("[thing]")
|
expect(property).toEqual("[thing]")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe("check manifest", () => {
|
||||||
|
it("should be able to retrieve the manifest", () => {
|
||||||
|
const manifest = getManifest()
|
||||||
|
expect(manifest.math).not.toBeNull()
|
||||||
|
expect(manifest.math.abs.description).toBe("Return the magnitude of `a`.")
|
||||||
|
})
|
||||||
|
})
|
Loading…
Reference in New Issue