0

I'm using the Mustache alias loader from this post to dynamically load partials (based on URL variables) into my default template.

This works like a charm, however, in some cases I would also like to load "regular" partials. Is there a way to combine both the dynamic alias loader and the regular partial loading?

Community
  • 1
  • 1
jnaklaas
  • 1,619
  • 13
  • 16

1 Answers1

1

Yep! You can use the Cascading Loader to load both alias and regular partials. Something like this should do the trick:

$partials = [
  'sidebar' => 'themes/custom/sidebar',
];

$loader = new Mustache_Loader_CascadingLoader([
  new FilesystemAliasLoader('path/to/partials', $partials),
  new Mustache_Loader_FilesystemLoader('path/to/partials'),
]);
bobthecow
  • 5,047
  • 25
  • 27