duncan3dc / blade

Use Blade templates without the full Laravel framework
Apache License 2.0
145 stars 36 forks source link

Could not reach BladeInstance->getViewFactory() method #10

Closed Sc3n3 closed 7 years ago

Sc3n3 commented 8 years ago

Hi, I want to add file extension like these;

$instance = new BladeInstance($views, $cache); $instance->getViewFactory()->addExtension('blade', 'blade'); $instance->getViewFactory()->addExtension('html', 'php');

But, that method is protected, and i cant reach it outside of the class. Could you set it to public or add new public method to reach it?

Thanks.

duncan3dc commented 8 years ago

It looks like the addExtension() method is not part of the Illuminate\Contracts\View\Factory interface.

I can understanding adding support for:

$instance->addExtension("blade");

But for your second example, we don't register a "php" compiler, so we'd need to also allow a way of defining additional compilers

imgangge commented 7 years ago

Hi @duncan3dc Like assign or with(Illuminate\View\View::with) before render. Or like implements \Yaf\View_Interface

duncan3dc commented 7 years ago

@ccuniverse Sorry I don't understand, you call with() on the View, not the factory, eg:

$blade = new \duncan3dc\Laravel\BladeInstance("/var/www/views", "/var/www/cache/views");
$view = $blade->make("github.example");
$view->with("date", "Today");
$html = $view->render();

Do you have some sample code to illustrate the use case for getViewFactory()?

duncan3dc commented 7 years ago

Please feel free to re-open this pr if you can provide a use case, thanks