/** * Get the evaluated view contents for the given view. * * @param string $view * @param array $data * @param array $mergeData * @return \Illuminate\View\View */ public static function view($view = null, $data = [], $mergeData = []) { $views = self::base_dir() . 'resources/views'; $cache = self::base_dir() . 'resources/cache'; $blade = new Blade($views, $cache); return $blade->view()->make($view, $data, $mergeData); }
/** * Render Blade template * * @param string $template template path * @param array $params parameters array for template */ public function render($template, array $params, $disabledebug = false) { $ret = ""; try { if ($this->_container == null) { throw new \Exception("Missing Dependency Container, add it with setContainer Method"); } \Debug::startMeasure('initblade', 'Init blade templating environnment'); $cachepath = CACHEPATH . DS . 'blade'; $views = $this->getPathArray(); $blade = new Blade($views, $cachepath); // get blade compiler $compiler = $blade->getCompiler(); // add use directive $compiler->directive('use', function ($expression) { return "<?php use {$expression}; ?>"; }); \Debug::stopMeasure('initblade'); if (DEVELOPMENT_ENVIRONMENT && $disabledebug == false) { \Debug::startMeasure('renderblade', 'Blade rendering'); // render the template file and echo it $ret = $blade->view()->make($template, $params)->render(); \Debug::stopMeasure('renderblade', 'Blade rendering'); } else { $ret = $blade->view()->make($template, $params)->render(); } } catch (\Exception $e) { throw new \Exception($e->getMessage()); } return $ret; }
/** * A function to make it easy to link to blade templates. * * @param $view * @param array|null $array * @return mixed */ function makeView($view, $array = []) { $viewsPath = __DIR__ . "/app/views"; $viewsCachePath = __DIR__ . "/app/cache"; $blade = new Blade($viewsPath, $viewsCachePath); echo $blade->view()->make($view, $array)->render(); }
/** * @return \Philo\Blade\Blade */ public static function instance() { if (static::$_instance === null) { $blade = new Blade(BASE_PATH . "/app/views", BASE_PATH . "/app/cache"); static::$_instance = $blade->view(); } return static::$_instance; }
/** * Rendu de vue avec le moteur Laravel/Blade * @param string $page * @param array $data */ public function renderBlade($page, $data = null) { $blade = new Blade($this->path_views, $this->path_cache); if (is_null($data)) { echo $blade->view()->make($page)->render(); } else { echo $blade->view()->make($page, $data)->render(); } }
public function render($templateName, $vars = null) { $this->logger = Logger::getLogger(__CLASS__); $blade = new Blade(array($this->templatesDir, $this->viewsDir), $this->cacheDir); $blade->view()->share('webroot', WEB_ROOT); $blade->view()->share('currentUrl', str_replace(WEB_ROOT, '/', $this->viewFacade->getRequest()->getRequestUri())); $result = $blade->view()->make(basename($templateName, '.blade.php'), $vars); $this->logger->debug('Render "' . $templateName . '" with Blade engine'); return $result; }
/** * @param string $template * * @return string */ function render($template) { global $__env; if (!ends_with($template, '.php')) { //error_log('cache: ' . $template); return $template; } $this->blade->view()->addExtension('php', 'blade'); $view = $this->blade->view()->file($template)->render(); $cache = $this->blade->getCompiler()->getCompiledPath($template); $__env = $this->blade->view(); return $cache; }
/** * @param String $view * @return mixed */ protected function normalizeView($view) { $directory = pathinfo($view, PATHINFO_DIRNAME); $viewFile = pathinfo($view, PATHINFO_FILENAME); $this->blade->view()->getFinder()->addLocation($directory . '/'); return $viewFile; }
/** * * @param string $viewpath * @param \Illuminate\Events\Dispatcher $events */ public function __construct($viewpath, \Illuminate\Events\Dispatcher $events = null) { if (is_empty($viewpath)) { throw new NullArgumentException($viewpath); } $cachePath = self::InitCachePath(); if (is_undefined($cachePath)) { throw new BladeCacheException(); } parent::__construct((array) $viewpath, $cachePath, $events); }
/** * Apply the data to configure the theme */ public function run() { $data = $this->getData(); // If blade is enabled, initialize it if ($this->isBladeEnabled()) { $bladeConfig = $data['blade']; // Setup blade and paths $viewsPath = $bladeConfig['paths']['views']; $cachePath = $bladeConfig['paths']['cache']; $blade = new Blade($viewsPath, $cachePath); // Extend blade /** @var \Illuminate\View\Compilers\BladeCompiler $compiler */ $compiler = $blade->getCompiler(); $extensions = array(new WordPressLoopExtension(), new WordPressQueryExtension(), new WordPressShortcodeExtension()); /** @var Extension $ext */ foreach ($extensions as $ext) { $ext->register($compiler); } // Set the blade engine in the facade Baobab::setBlade($blade); } }
/** * Sets up template engine to mimic Laravel. * * @param BladeDirectiveInterface $directive * @return Blade */ private function setUpTemplateEngine(BladeDirectiveInterface $directive) { list($views, $cache) = $this->createTestWorld(); $blade = new Blade($views, $cache); $blade->getCompiler()->directive($directive->openingTag(), [$directive, 'openingHandler']); $blade->getCompiler()->directive($directive->closingTag(), [$directive, 'closingHandler']); return $blade; }
public function blade($file, $vars = array()) { $blade = new Blade(VIEWPATH, CACHEPATH); echo $blade->view()->make($file, $vars)->render(); }
/** * Render a view * @param string $view The view path * @return void */ public function render($view, $data = array()) { $data = apply_filters('Municipio/blade/data', $data); $blade = new Blade($this->VIEWS_PATHS, $this->CACHE_PATH); echo $blade->view()->make($view, $data)->render(); }
/** * Displays the given view * @param string $template The view path (if in subfolder) and filename * @param boolean $displayErrors Weather to output errors or not * @return boolean */ public static function show($view, $data = array()) { $blade = new Blade(VIEWS_PATH, CACHE_PATH); echo $blade->view()->make($view, $data)->render(); return true; }
<?php require 'bootstrap.php'; // Using the Laravel's Blade Templating... use Philo\Blade\Blade; $views = __DIR__ . '/views'; $cache = __DIR__ . '/cache'; $blade = new Blade($views, $cache); echo $blade->view()->make('hello')->render();
<?php require 'vendor/autoload.php'; use Philo\Blade\Blade; $dir = ['views' => __DIR__ . '/../views', 'cache' => __DIR__ . '/../cache', 'dist' => __DIR__ . '/../dist', 'config' => __DIR__ . '/../config']; $blade = new Blade($dir['views'], $dir['cache']); $blade->view()->share(['version' => time(), 'assets' => 'assets/']); foreach (['all', 'forwards', 'defensemen', 'goalies'] as $position) { $blade->view()->share(['position' => $position]); $html = $blade->view()->make($position, ['players' => include $dir['config'] . '/players.php', 'statistics' => include $dir['config'] . '/' . $position . '.php']); file_put_contents($dir['dist'] . '/' . ($position == 'all' ? 'index' : $position) . '.html', $html); }
<?php require 'vendor/autoload.php'; use Philo\Blade\Blade; use Carbon\Carbon; use Michelf\Markdown; setlocale(LC_ALL, "en_US.UTF-8"); $dir = ['views' => __DIR__ . '/../views', 'cache' => __DIR__ . '/../cache', 'dist' => __DIR__ . '/../dist']; $authors = ['dominic' => ['name' => 'Dominic Martineau', 'img' => 'assets/img/dominicmartineau.jpg']]; $blade = new Blade($dir['views'], $dir['cache']); $blade->view()->share(['version' => time(), 'assets' => 'assets/']); $articles = json_decode(file_get_contents($dir['views'] . '/articles/articles.json'), true); $articles = $articles['articles']; $posts = []; // Blog articles foreach ($articles as $index => $article) { // Next $next = $previous = null; if (isset($articles[$index - 1])) { $next = ['uri' => $articles[$index - 1]['uri'], 'title' => $articles[$index - 1]['title'], 'date' => Carbon::createFromFormat('Ymd', $articles[$index - 1]['date']), 'intro' => $articles[$index - 1]['intro']]; } else { if (isset($articles[$index + 1])) { $previous = ['uri' => $articles[$index + 1]['uri'], 'title' => $articles[$index + 1]['title'], 'date' => Carbon::createFromFormat('Ymd', $articles[$index + 1]['date']), 'intro' => $articles[$index + 1]['intro']]; } } $file = $dir['views'] . '/articles/' . $article['uri'] . '.md'; $blade->view()->share(['title' => $article['title'], 'body' => 'article', 'date' => Carbon::createFromFormat('Ymd', $article['date']), 'description' => ""]); $html = $blade->view()->make('article', ['title' => $article['title'], 'description' => $article['intro'], 'author' => $authors[$article['author']], 'date' => Carbon::createFromFormat('Ymd', $article['date']), 'content' => Markdown::defaultTransform(file_get_contents($file)), 'share' => ['url' => 'http://blog.lygue.com/' . $article['uri'] . '.html', 'title' => $article['title'], 'body' => $article['intro']], 'next' => $next, 'previous' => $previous, 'page' => '']); file_put_contents($dir['dist'] . '/' . $article['uri'] . '.html', $html); } $pages_articles = array_chunk($articles, 5);
<?php require 'db.php'; require 'vendor/autoload.php'; use Philo\Blade\Blade; $views = __DIR__ . '/template'; $cache = __DIR__ . '/cache'; $blade = new Blade($views, $cache); $results = query(); $params = array(); $choiceMap = array('1' => 'Clothes', '2' => 'Food', '3' => 'House', '4' => 'Medical Care', '5' => 'Move'); foreach ($results['rows'] as $result) { $doc = $result['doc']; $doc['choice'] = $choiceMap[$doc['digits']]; $params[] = $doc; } echo $blade->view()->make('table')->with('params', $params)->render();
<?php ini_set('display_errors', 1); require 'vendor/autoload.php'; use Philo\Blade\Blade; $views = __DIR__ . '/views'; $cache = __DIR__ . '/cache'; $blade = new Blade($views, $cache); $data = ['title' => 'Judul']; echo $blade->view()->make('hello', $data)->render();
public function __construct(Collection $container) { $this->_container = $container; $config = $this->_container->get('settings'); parent::__construct($config->get('app.views_path'), $config->get('cache.path')); }
<?php require 'admin.php'; use Philo\Blade\Blade; $views = __DIR__ . '/template'; $cache = __DIR__ . '/cache'; $blade = new Blade($views, $cache); $phoneNumber = '+81345402625'; $params = array('phoneNumber' => $phoneNumber); if ($p = adminQuery($phoneNumber)) { $params = array_merge($params, $p); } echo $blade->view()->make('scenario')->with('params', $params)->render();
/** * Returns view rendered by Blade on the View layer * * @param mixed * @return void */ function view($view) { $v = new Blade(File::find($view, 'View', true, true), APPPATH . 'Cache'); return $v->view()->make($view); }
/** * Write a blade template to the a slim response body * * @param Psr\Http\Message\ResponseInterface $response The slim response to write to * @param string $template The blade template to render * @param array $args Arguments to pass to the blade template * @return void */ public function render($response, $template, $args = []) { return $response->getBody()->write($this->bladeInstance->view()->make($template, $args)->render()); }
/** * Replace all stub tokens with properties. * * @param $view_name * @param $table * @param $activitylog * * @return mixed|string */ protected function generateView($view_name, $table, $activitylog = false) { $properties = $this->getTableProperties($table); $uses = []; $foreign_keys = $properties['foreign_keys']; foreach ($foreign_keys as $key => $val) { $properties['foreign_keys'][$key]->referenced_class_name = Util::Table2ClassName($val->referenced_table_name); } $columns_json = []; foreach ($properties['columns'] as $key => $value) { $columns_json[$value['name']] = 'foo'; } if ($properties['softdeletes']) { $uses[] = 'SoftDeletes'; } if ($activitylog) { $uses[] = 'LogsActivity'; } $blade = new Blade($this->views, $this->cache); return $blade->view()->make($view_name, ['activitylog' => $activitylog, 'class' => $this->class, 'columns' => $properties['columns'], 'columns_json' => json_encode($columns_json), 'fillable' => Util::Array2String($properties['fillable']), 'guarded' => Util::Array2String($properties['guarded']), 'hidden' => Util::Array2String($properties['hidden']), 'foreign_keys' => $properties['foreign_keys'], 'table' => $table, 'timestamps' => $properties['timestamps'], 'uses' => implode(',', $uses), 'softdeletes' => $properties['softdeletes']])->render(); }
/** * @param Link $link */ public function showLink(Link $link) { return $this->replaceInjectedVars($this->blade->view()->make('elements.link', array('link' => $link))); }