-
-
Notifications
You must be signed in to change notification settings - Fork 512
Closed
Labels
Description
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
- Existing functionality for
Timber::renderandTimber::compilestill work - Themes and multiple plugins can set different rules for the location of twig files
- New methods are documented in wiki
- Method for populating context for template is documented
- Functionality for caching is preserved, new syntax/method is documented
- Review API with 2 collaborators for sanity-check
- Reference of files within twig (extension, inclusion) is considered
- Reference of files within twig (extension, inclusion) is documented
... 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
$view = new TimberView();
$view->context['post'] = new TimberPost();
$view->cache(600);
$view->render('single.twig');Plugin example with custom locations
$view = new TimberView('my-plugin-context');
$view->cache(600);
$view->context['days'] = my_plugin_get_days_or_something();
$templates = array(
get_template_directory(),
get_template_directory().'/templates',
__DIR__.'/templates'
);
return $view->compile('calendar-overview.twig', $templates);Reactions are currently unavailable