finos / finos/architecture-as-code

Enhancement: Support Directory Structure for Template Bundles in CALM

Open
#1,032 0 comments 0 reactions 0 assignees View on GitHub
templating
Dominant language
TypeScript
Stars
399
Forks
138
Avg merge
2d 6h
Merged PRs (30d)
38

Description

## Summary
Currently, all templates in a template bundle must reside in the same directory. This enhancement request proposes adding support for a nested directory structure, improving maintainability and organization for complex template bundles.

## Proposed Changes
1. **Support Nested Directories:** Modify the template loading mechanism to recursively scan directories for template files.
2. **Allow Relative Paths in `index.json`:** Update `index.json` to support referencing templates in subdirectories.
3. **Enhance Partial Resolution:** Ensure Handlebars partials can be resolved even if they are in nested directories.
4. **Backward Compatibility:** Ensure existing flat-structured template bundles continue to function as before.

## Benefits
- **Better Organization:** Allows logically grouping related templates in subdirectories.
- **Scalability:** Enables larger template bundles without cluttering a single directory.
- **Improved Maintainability:** Easier to manage and extend templates without increasing complexity.

## Example
### Current Structure (Flat)
```
/template-bundles/docusaurus/
├── index.json
├── node.mdx.hbs
├── sidebar.js.hbs
├── relationships.hbs
├── row-template.html
```

### Proposed Structure (Nested)
```
/template-bundles/docusaurus/
├── index.json
├── templates/
│ ├── pages/
│ │ ├── node.mdx.hbs
│ ├── components/
│ │ ├── sidebar.js.hbs
├── partials/
│ ├── relationships.hbs
│ ├── row-template.html
```

## Implementation Notes
- Modify the template resolver to handle directory traversal.
- Update `index.json` schema to allow referencing subdirectories.
- Ensure Handlebars partials can be loaded from nested paths.

## Acceptance Criteria
- [ ] Templates can be stored in nested directories.
- [ ] `index.json` supports relative paths to templates.
- [ ] Partial resolution works correctly with nested directories.
- [ ] Existing flat-structured template bundles continue to work.

---

**Related Issues:**
Create an Architecture Documentation Website from CALM [#478](https://github.com/finos/architecture-as-code/issues/478)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.