Skip to content

External template engines should be lazy loadable #178

judofyr opened this Issue Mar 12, 2013 · 4 comments

3 participants

judofyr commented Mar 12, 2013

Even though we're pushing for moving the actual template classes out of Tilt for 2.0, I see the value of having the template extension mapping inside of Tilt. Just something simple that says that .slim is mapped to require "slim", and Tilt['index.slim'] will lazily load the template class from another gem.

In multithreaded environments we would still recommend requiring eagerly, but this feature is useful for CLI tools or places where racing conditions are not a problem.

This is related to #160. In fact, #160 could have been implemented on top of this feature.

rkh commented Mar 12, 2013

Yes, I have been thinking about this. If the outside code interfacing with Tilt doesn't have to care whether or not the engine ships with tilt, it would also be possible to slowly move engines out of the Tilt gem.

I would also like to solve the autoload issue at the same time. We could simply have a lock around the lazy load code, for instance.

minad commented Mar 12, 2013

Good idea!

@judofyr judofyr added a commit that referenced this issue May 1, 2013
@judofyr judofyr Refactor into Tilt::Mapping:
- Allow multiple mappings with Tilt::Mapping
- Replace global state with a Tilt::Mapping-instance
- Implement lazy loading (#160, #178)
- Remove initialize_template_engine and engine_initialized?
judofyr commented May 2, 2013

Please see #187 for a proposed solution.

judofyr commented May 12, 2013

This is now possible:

Tilt.register_lazy "Slim::Template", 'slim/template', 'slim'
@judofyr judofyr closed this May 12, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.