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.
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.
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?
Please see #187 for a proposed solution.
This is now possible:
Tilt.register_lazy "Slim::Template", 'slim/template', 'slim'