feature request: provide current resource path to model and resourceLoader
- Dominant language
- HTML
- Stars
- 49
- Forks
- 20
- Avg merge
- 3h 46m
- Merged PRs (30d)
- 1
Description
During runtime resources can be loaded recursively.
## Example
For example if we would have the following resource loading:
```
main.htl
-> child.htl
-> grandchild.htl
-> grandchild.htl
```
click here to expand markup example
main.htl
```
```
and in resourceItem you have
child.htl
```
```
grandchild.htl
```
${myModel.title}
```
## Motivation
This resource path information is often used to return the according model data.
In the example above both `grandchild.htl` could render different data from the same model name.
## API
It would be most convenient if the resourcePath could be an array e.g. `['root', 'resourceItem', 'childResourceItem1']` and would be available at two locations:
### `compiler.withModuleImportGenerator`
Although the `resourcePath` is a runtime only value we could still provide it to the Model mapper e.g.:
```js
compiler.withModuleImportGenerator((baseDir, varName, moduleId) => const ${varName} = function Model() { ...
```
could be changed to:
```js
compiler.withModuleImportGenerator((baseDir, varName, moduleId) => const ${varName} = function Model(resourcePath) { ...
```
### `runtime.withResourceLoader`
Inside the runtime it would also be nice to provide this resourceParameter for resource loading:
```js
runtime.withResourceLoader((runtime, resourceName, resourceParameters) => {
```
```js
runtime.withResourceLoader((runtime, resourceName, resourceParameters, resourcePath) => {
```
Contributor guide
Assessment
This issue has not been assessed yet.