-
Notifications
You must be signed in to change notification settings - Fork 1
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
A way to create an engine that can retrieve templates dynamically #5
Comments
So I'm not sure exactly how egs works, but usually when parsing out data, for a template or some other system that makes external references, you have to break down the system a bit:
|
I don't plan on exposing the cache system outside the internals, it seems highly unnecessary. Being able to provide a function that returns a string that is usable from inside a |
The purpose of a cache is to provide the compiler with the complete collection of templates it's going to be using, including the target template, thus isolating the parts of the template system that require asynchronous operations, e.g. fetching from the database or fetching off the filesystem. So I don't know how you don't expose it, it's kind of necessary. |
Oh, that's already handled through the Package system. You can compile a directory of |
It seems like there's two different utilities doing the same function then, that serve as an in-memory storage location to retrieve templates from. Ideally I should be able to gather a collection of templates, even of different source formats, collect them all in memory, and pass that to the respective compilers without any asynchronous operations. |
Well, the Package system doesn't hold templates, it holds compiled functions. That's why you don't need the full egs, just the runtime portion. In order to jury-rig other templates in, they'd need to also be precompiled, and trying to get it all to fit nicely is something extremely low priority for me, especially when you could simply provide a function to the egs template system to do it for you. { context: { renderJade: someFunction } }. However that function works is an exercise for the reader. |
In the event that a dev stores a template in a database or otherwise not on a local filesystem, there could be a way to allow them to provide something of a dynamic filesystem.
There should be really only two functions that need to be provided:
(1): a way to retrieve the (precompiled) template given a path, as well as an mtime or some other cache identifier
(2): whether or not a template is out of date, based on the previously provided mtime or cache identifier.
The text was updated successfully, but these errors were encountered: