-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature request: allow resource precompiling #198
Comments
The problem is that the resource that is included depends on dynamic variables. your example is an edge case, where you know the resource type before hand, but most often, the resource type is based on the content, like in the accordion component: I think it would be possible to create a list of resource calls during compilation, so that you can detect the ones that have static component type reference, and precompile and pre-render those components. but the actual resource include still needs to happen during runtime. but your resource resolver can then fallback to the pre-rendered ones.
Storybookjs/aem makes this happen by configuring all possible components. Also, the story itself provides the content, so the resource resolver can be purely client side: ps: As a side note: in AEM, the resource include could also be served by a JSP or servlet, as it depends on the component resolution.... |
hey @tripodsan thanks for explaining the dynamic resource loading - as you already assumed I had only the static case in mind.
Although it would work only for static cases it would still be really awesome to reduce the amount of wiring efforts and to reduce maintenance efforts. The approach in AEM Storybook is probably the best possible way to solve dynamic resource loading and/or to work as fallback 👍 Thanks also for bringing up ps: regarding the accordion - I know this is the correct way to handle it in AEM (and that's totally fine) but modern template languages handle those cases slightly differently by providing the html directly into components as described in adobe/htl-spec#67 |
the
@adobe/htlengine
supports two ways to include content into a template:data-sly-call
The directive
data-sly-use
is executed during compile time and uses the@adobe/htlengine
templateLoader to include the html file.During runtime it executes the template:
data-sly-resource
The directive
data-sly-resource
is executed only during runtime and therefore we are not able precompile the template inproject/components/content/articleTeaser/teaserItem
although it is already known.will be compiled to:
const var_resourceContent1 = yield $.slyResource("teaserItem", {"resourceType": "project/components/content/articleTeaser/teaserItem", });
Would it be possible to add a feature similar to the
defaultModuleGenerator
which allows custom precompiling fordata-sly-use
also fordata-sly-resource
?The main motivation behind this feature request is the goal to run
data-sly-resource
inside a browser without the need of a running server to render the resource template.Right now the compiler accepts a moduleMap with the argument called
mods
:One idea how we might achieve add is new feature would be to rename
mods
tometa
and allow a substructure like thisThat way we could add a preprocessor api for the resources and allow modifications during compile time:
The text was updated successfully, but these errors were encountered: