Support Nunjucks templating engine for API call construction #30
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
(addresses #26)
This PR allows
bteEdges
to supply theirinput
property as an object and specifyparams
andbody
properties as Nunjucks templates, allowing for multiple inputs and more flexible parameter/etc. creation.x-BTE
Example for non-TRAPI queries:
We want each item in
someDataField
, but we want to remove the prefixes, and concatenate them with a delimiter into a single string.This will result in
someParameter
being"id0,id1,id2"
. URLs may make use of this viapath_param
. Unlike in #28,input
is simplified to remove nested per-param namespaces, and html is not automatically escaped.TRAPI
TRAPI queries may take multiple inputs (and use templating) to ids using
input.ids
, and may use templating/multiple inputs in n0 and n1categories
as well as e01predicates
.Filter Functions
Finally, nunjucks supports filter functions. It comes with a number of builtins, while this PR supplies the following, which may be applied individually or on an array of strings:
substr(begin, end)
: slice a stringaddPrefix(prefix, delim)
: add a prefix, with delimiter between prefix and string defaulting to:
rmPrefix(delim)
: remove a prefix by splitting by delimiter and removing first string, with delimiter defaulting to:
replPrefix(prefix, delim)
replace a prefix by usingrmPrefix
andaddPrefix
in order, using same delimiter.For each of the above,
delim
is an optional argument, andsubstr
has the same options and behavior as String.prototype.slice().