@peter.naydenov/morph 3.1.5 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.mocharc.json +1 -0
- package/.opencode/command/speckit.analyze.md +184 -0
- package/.opencode/command/speckit.checklist.md +294 -0
- package/.opencode/command/speckit.clarify.md +181 -0
- package/.opencode/command/speckit.constitution.md +82 -0
- package/.opencode/command/speckit.implement.md +135 -0
- package/.opencode/command/speckit.plan.md +89 -0
- package/.opencode/command/speckit.specify.md +257 -0
- package/.opencode/command/speckit.tasks.md +137 -0
- package/.opencode/command/speckit.taskstoissues.md +28 -0
- package/.specify/memory/constitution.md +43 -0
- package/.specify/scripts/bash/check-prerequisites.sh +166 -0
- package/.specify/scripts/bash/common.sh +156 -0
- package/.specify/scripts/bash/create-new-feature.sh +305 -0
- package/.specify/scripts/bash/setup-plan.sh +61 -0
- package/.specify/scripts/bash/update-agent-context.sh +790 -0
- package/.specify/templates/agent-file-template.md +28 -0
- package/.specify/templates/checklist-template.md +40 -0
- package/.specify/templates/plan-template.md +104 -0
- package/.specify/templates/spec-template.md +115 -0
- package/.specify/templates/tasks-template.md +251 -0
- package/Changelog.md +17 -0
- package/README.md +184 -13
- package/dist/methods/build.d.ts +28 -2
- package/dist/methods/render.d.ts +9 -20
- package/dist/morph.cjs +1 -1
- package/dist/morph.esm.mjs +1 -1
- package/dist/morph.umd.js +1 -1
- package/morph.png +0 -0
- package/package.json +3 -2
- package/simple.js +17 -0
- package/specs/001-extend-templates/checklists/requirements.md +35 -0
- package/specs/001-extend-templates/contracts/set-method.json +39 -0
- package/specs/001-extend-templates/data-model.md +76 -0
- package/specs/001-extend-templates/plan.md +90 -0
- package/specs/001-extend-templates/quickstart.md +56 -0
- package/specs/001-extend-templates/research.md +18 -0
- package/specs/001-extend-templates/spec.md +139 -0
- package/specs/001-extend-templates/tasks.md +255 -0
- package/src/methods/_readTemplate.js +22 -46
- package/src/methods/_renderHolder.js +13 -7
- package/src/methods/_setupActions.js +1 -8
- package/src/methods/build.js +458 -321
- package/src/methods/render.js +23 -46
package/src/methods/render.js
CHANGED
|
@@ -1,57 +1,34 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
import _renderHolder from './_renderHolder.js'
|
|
2
3
|
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* @param {
|
|
12
|
-
* @param {
|
|
13
|
-
* @param {
|
|
14
|
-
* @param {object} original - Original data context for full data access
|
|
15
|
-
* @param {object} dependencies - External dependencies available to helpers
|
|
16
|
-
* @param {...any} args - Additional arguments passed to the render function
|
|
17
|
-
*
|
|
18
|
-
* @returns {string} Rendered string result
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* // Render with function helper
|
|
22
|
-
* const result = render(data, 'myHelper', helpers, originalData, deps);
|
|
7
|
+
* Renders a helper or template with the provided data and context.
|
|
8
|
+
*
|
|
9
|
+
* @param {any} theData - The data to process.
|
|
10
|
+
* @param {string} name - The name of the helper or template to render.
|
|
11
|
+
* @param {object} helpers - Dictionary of available helpers.
|
|
12
|
+
* @param {any} original - The full original data context.
|
|
13
|
+
* @param {object} dependencies - injected dependencies.
|
|
14
|
+
* @param {...any} args - Additional arguments.
|
|
23
15
|
*
|
|
24
|
-
* @
|
|
25
|
-
* // Render with template
|
|
26
|
-
* const result = render(data, 'myTemplate', helpers, originalData, deps);
|
|
16
|
+
* @returns {any} The result of the rendering process.
|
|
27
17
|
*/
|
|
28
|
-
function render ( theData, name, helpers, original, dependencies, ...args
|
|
29
|
-
|
|
30
|
-
if (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
* @returns {object} Returns { text: d } if d is string, otherwise returns d unchanged
|
|
41
|
-
*/
|
|
42
|
-
function setRenderData ( d={} ) {
|
|
43
|
-
if ( typeof d === 'string' ) return { text: d }
|
|
44
|
-
else return d
|
|
45
|
-
} // setRenderData func.
|
|
46
|
-
const isRenderFunction = typeof helpers[name] === 'function'; // Render could be a function or template.
|
|
47
|
-
theData = setRenderData ( theData )
|
|
48
|
-
|
|
49
|
-
if ( isRenderFunction ) return helpers[name]( { theData, dependencies, full:original}, ...args )
|
|
50
|
-
else return _renderHolder ( helpers[name], theData )
|
|
18
|
+
function render ( theData, name, helpers, original, dependencies, ...args) {
|
|
19
|
+
const useHelper = ( targetName, targetData ) => render ( targetData || theData, targetName, helpers, original, dependencies, ...args )
|
|
20
|
+
if (!helpers[name]) return `( Error: Helper '${name}' is not available )`
|
|
21
|
+
|
|
22
|
+
const isRenderFunction = typeof helpers[name] === 'function';
|
|
23
|
+
|
|
24
|
+
if ( isRenderFunction ) return helpers[name]({ data: theData, dependencies, full: original, useHelper }, ...args)
|
|
25
|
+
else {
|
|
26
|
+
let dataForHolder = theData
|
|
27
|
+
if ( typeof theData !== 'object' || theData === null ) dataForHolder = { text: theData }
|
|
28
|
+
return _renderHolder ( helpers[name], dataForHolder )
|
|
29
|
+
}
|
|
51
30
|
} // render func.
|
|
52
31
|
|
|
53
32
|
|
|
54
33
|
|
|
55
34
|
export default render
|
|
56
|
-
|
|
57
|
-
|