-
Notifications
You must be signed in to change notification settings - Fork 19
Open
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
<sly
data-sly-resource="${'resourceItem' @ resourceType='child'}"
/>
and in resourceItem you have
child.htl
<sly
data-sly-resource="${'childResourceItem1' @ resourceType='grandchild'}"
/>
<sly
data-sly-resource="${'childResourceItem2' @ resourceType='grandchild'}"
/>
grandchild.htl
<sly data-sly-use.myModel="com.foo.core.models.myModel"/>
${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.:
compiler.withModuleImportGenerator((baseDir, varName, moduleId) => const ${varName} = function Model() { ...could be changed to:
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:
runtime.withResourceLoader((runtime, resourceName, resourceParameters) => {runtime.withResourceLoader((runtime, resourceName, resourceParameters, resourcePath) => {Metadata
Metadata
Assignees
Labels
No labels