latte icon indicating copy to clipboard operation
latte copied to clipboard

Add namespace loader

Open alexander-schranz opened this issue 3 years ago • 2 comments

  • bug fix / new feature? #314
  • BC break? no
  • doc PR: nette/docs#???

This introduce a namespace loader. This allows to use a namespace like app:: similar to Plates and Blade template engine.

Usage:

    $defaultLoader = new FileLoader(__DIR__ . '/templates');
    $emailLoader = new FileLoader(__DIR__ . '/emails');
    $someLoader = new FileLoader(__DIR__ . '/vendor/some/some/templates');
    $otherLoader = new StringLoader(['main' => 'othercontent']);

    $loader = new NamespaceLoader([
        '' => $defaultLoader,
        'email' => $emailLoader,
        'some' => $someLoader,
        'other' => $otherLoader,
    ]);

This way it is very flexible as we can use any loader again.

alexander-schranz avatar Nov 01 '22 15:11 alexander-schranz

@dg looks like you rebased it. Do I need to change the target branch?

Edit: Oh my fault looks like the master was force pushed to another state. I will rebase my branch.

alexander-schranz avatar Nov 05 '22 14:11 alexander-schranz

It looks like @dg has been rebasing this diligently for 2 years. I am also very interested in this feature (the thing I'm trying to do right now likely won't really work without it), as currently there seems to be no way to reference a layout that is not in the same directory as the template, or else have relative paths defined in the {layout} block (ew).

Is there something we users could do to help move this forward, or get attention on it?

Crell avatar Jul 19 '24 00:07 Crell