-
-
Notifications
You must be signed in to change notification settings - Fork 506
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
Create TimberView object to handle view rendering #261
Comments
I really like the idea behind this API. How do you feel about |
@bryanaka, yeah, I think it's wise to have a constant like that. In my thinking, the use-case is for when you want to easily prepend or append a custom path before/after the default locations. Did you have another use-case in mind? |
No, that is exactly the use-case in mind. sounds fair enough to me. So I am basically mimicking this API in a project I just started (thus my re-entry to Timber 😉 ), the only thing I changed was exposed a |
Hi, Is there any plans to complete this feature? I'm trying to use Timber in a plugin and would like it to work with both themes that use Timber and themes that don't. Is there any current solutions how I can bypass the fact that I cannot change the locations after first initialisation? Would it be safe to use absolute uris in the plugin and not to set the locations at all so the theme can do that if wanted? |
@jarednova - are there any plans about this? |
I wanted to use Timber in a plugin and investigated how all this works. What surprised me is the fact that we almost have the working functionalaty to use separate templates even for each plugin / theme. There is something like function filter_paths() {
return [__DIR__.'/front'];
}
add_filter('timber/loader/paths', 'filter_paths');
Timber::render('admin.twig', $context);
remove_filter('timber/loader/paths', 'filter_paths'); I know it's not pretty, but it's a quite well functioning workaround to problem with I think it solves all the problems mentioned in #248. Or maybe it's too late and I don't see some obvious problem :) |
I'm closing all 2+ year old issues. If someone wants to pick this up, let's make it a fresh issue |
This is from the discussion in #248 and the #259 epic. Create a new object to better organize how templates are rendered and locations are chosen. This will deprecate (but not eliminate) the current static-based approach to data and rendering.
Acceptance
Timber::render
andTimber::compile
still work... this work is currently in: https://github.com/jarednova/timber/tree/timber-view. Here's a sample of the API that someone might use in
single.php
:Basic theme example with standard locations
Plugin example with custom locations
The text was updated successfully, but these errors were encountered: