Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Loading templates from string #36

Open
Bilge opened this issue Oct 9, 2021 · 2 comments
Open

Loading templates from string #36

Bilge opened this issue Oct 9, 2021 · 2 comments
Labels
question Further information is requested

Comments

@Bilge
Copy link

Bilge commented Oct 9, 2021

Hi. I use Twing to integrate Twig templates into Storybook and that works great when you want to build a story around an external Twig template.

Now suppose I wanted to write a story around a component that should be embedded but doesn't have any concrete implementations. Then I would construct the source template in a string but I would not be able to use import any more, since the template is a string in memory and not a file on disk, and twing-loader would not be able to do its magic. How, then, should I load such a template that is stored in a string (that may use {% embed %} to reference other templates)?

@ericmorand
Copy link
Member

Hi @Bilge.

When would the template be created? At run-time? Or at compile-time?

In a classic Twing context, I would use an instance of TwingLoaderArray loader (in conjunction with a TwingLoaderChain to hold both the array loader and the filesystem ones) where I would add the template whenever needed. It should be easy to use the same pattern with twing-loader since twing-loader expect an instance of TwingEnvironment to be passed as parameter

@ericmorand ericmorand added the question Further information is requested label Oct 10, 2021
@Bilge
Copy link
Author

Bilge commented Oct 10, 2021

Runtime.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants