Пример #1
0
<?php

// --------------------------------------------------------------
// Set constants
// --------------------------------------------------------------
define('MUSTACHE_EXT', '.mustache');
// --------------------------------------------------------------
// Register classes
// --------------------------------------------------------------
Autoloader::map(array('Mustache' => __DIR__ . DS . 'mustache' . EXT, 'LaylaMustache' => __DIR__ . DS . 'laylamustache' . EXT));
// --------------------------------------------------------------
// Add event listeners
// --------------------------------------------------------------
Event::listen(View::loader, function ($bundle, $view) {
    return LaylaMustache::file($bundle, $view, Bundle::path($bundle) . 'views');
});
Event::listen(View::engine, function ($view) {
    // The Blade view engine should only handle the rendering of views which
    // end with the Blade extension. If the given view does not, we will
    // return false so the View can be rendered as normal.
    if (!str_contains($view->path, MUSTACHE_EXT)) {
        return;
    }
    if (count($view->data) > 1) {
        $mustache = new LaylaMustache();
        return $mustache->render(File::get($view->path), $view->data());
    }
    return File::get($view->path);
});
Пример #2
0
|
*/
Autoloader::directories(array(path('app') . 'models', path('app') . 'libraries'));
/*
|--------------------------------------------------------------------------
| Laravel View Loader
|--------------------------------------------------------------------------
|
| The Laravel view loader is responsible for returning the full file path
| for the given bundle and view. Of course, a default implementation is
| provided to load views according to typical Laravel conventions but
| you may change this to customize how your views are organized.
|
*/
Event::listen(View::loader, function ($bundle, $view) {
    return LaylaMustache::file($bundle, $view, Bundle::path($bundle) . 'views');
});
/*
|--------------------------------------------------------------------------
| Laravel Language Loader
|--------------------------------------------------------------------------
|
| The Laravel language loader is responsible for returning the array of
| language lines for a given bundle, language, and "file". A default
| implementation has been provided which uses the default language
| directories included with Laravel.
|
*/
Event::listen(Lang::loader, function ($bundle, $language, $file) {
    return Lang::file($bundle, $language, $file);
});