mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-03 23:11:00 +02:00
Squashed 'ai-context/trustgraph-templates/' content from commit 42a5fd1b
git-subtree-dir: ai-context/trustgraph-templates git-subtree-split: 42a5fd1b678f32be378062e30451e2052ccb95dd
This commit is contained in:
commit
74cc8a4685
1216 changed files with 116347 additions and 0 deletions
|
|
@ -0,0 +1,38 @@
|
|||
// Parameter Processing Module
|
||||
// Handles dynamic parameter replacement in configuration values
|
||||
// Replaces {parameter_name} placeholders with actual parameter values
|
||||
|
||||
{
|
||||
// Applies parameter substitutions to string values
|
||||
// Only processes strings - leaves other types unchanged
|
||||
substitute_parameters: function(value, parameters)
|
||||
if std.isString(value) then
|
||||
std.foldl(
|
||||
function(acc, param)
|
||||
// Only do string replacement if param.value is a string
|
||||
if std.isString(param.value) then
|
||||
std.strReplace(acc, "{" + param.key + "}", param.value)
|
||||
else
|
||||
acc, // Skip replacement for non-string parameter values
|
||||
std.objectKeysValuesAll(parameters),
|
||||
value
|
||||
)
|
||||
else
|
||||
value,
|
||||
|
||||
// Applies parameter substitutions to all values in an object
|
||||
// Recursively processes nested objects and arrays
|
||||
substitute_parameters_in_object: function(obj, parameters)
|
||||
if std.isObject(obj) then
|
||||
{
|
||||
[key]: $.substitute_parameters_in_object(obj[key], parameters)
|
||||
for key in std.objectFields(obj)
|
||||
}
|
||||
else if std.isArray(obj) then
|
||||
[
|
||||
$.substitute_parameters_in_object(item, parameters)
|
||||
for item in obj
|
||||
]
|
||||
else
|
||||
$.substitute_parameters(obj, parameters),
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue