Exemplo n.º 1
0
 /**
  * Use this in your templates to render views returned by the controllers
  *
  * @param \Illuminate\View\View $view The view to be rendered
  */
 public static function render($view)
 {
     try {
         echo $view->render();
     } catch (\Exception $e) {
         echo $e->getMessage();
     }
 }
Exemplo n.º 2
0
 /**
  * Publish a source file and/or pass to $next.
  *
  * @param Source $source
  * @param Closure $next
  * @param array $extensions
  * @return mixed
  */
 public function handle(Source $source, Closure $next, ...$extensions)
 {
     if ($this->isPublishable($source, $extensions)) {
         $view = new View($this->factory, $this->factory->getEngineFromPath($source->getPathname()), $this->files->get($source->getPathname()), $source->getPathname());
         $source->changeExtension(['.blade.php' => '.html'])->changeExtension(['.php' => '.html']);
         $this->write($source->getOutputPathname(), $view->render());
     }
     $next($source);
 }
Exemplo n.º 3
0
 /**
  * Render the user fields.
  *
  * @param \WP_User|string If adding a user, $user is the context (string): 'add-existing-user' for multisite, 'add.new-user' for single. Else is a \WP_User instance.
  */
 public function displayFields($user)
 {
     // Add nonce fields for safety.
     if (!static::$hasNonce) {
         wp_nonce_field('user', '_themosisnonce');
         static::$hasNonce = true;
     }
     // Set the value attribute for each field.
     $fields = $this->setDefaultValue($user, $this->fields);
     // User view data
     $params = ['__factory' => $this, '__fields' => $fields, '__sections' => $this->sections, '__user' => $user, '__userContext' => null];
     // Check if $user is a string context
     if (is_string($user)) {
         // Set to null __user
         $params['__user'] = null;
         // Set the context
         $params['__userContext'] = $user;
     }
     // Pass data to user view.
     $this->view->with($params);
     // Render the fields.
     echo $this->view->render();
 }
Exemplo n.º 4
0
 /**
  * Render the template.
  *
  * @return string
  */
 public function render()
 {
     return $this->view->render();
 }
 /**
  * Get the string contents of the view.
  *
  * @param  callable|null $callback
  * @return string
  * @throws Exception
  * @throws Throwable
  */
 public function render(callable $callback = null)
 {
     $rendered = parent::render($callback);
     $this->factory->getDispatcher()->fire("tempTemplateRendered", $this->getName());
     return $rendered;
 }
Exemplo n.º 6
0
 /**
  * Renders a Blade template with passed and stored symbol data.
  *
  * @param string $view - view name i.e.: 'sample' resolves to [template_path]/sample.blade.php
  * @param array  $data
  *
  * @return string
  */
 public function render($view, $data = [])
 {
     # resolve the view path based on the template paths and the view name
     $view = $this->view_finder->find($view);
     # collect data from the context and other places
     $data = parent::collectContext($data);
     # create an illuminate view from stored factory and blade engine
     $blade_view = new IlluminateView($this->factory, $this->blade_engine, NULL, $view, (array) $data);
     # render and return the result
     return $blade_view->render();
 }
Exemplo n.º 7
0
 /**
  * Takes a View and returns $this to further chain methods on.
  *
  * @param View $view
  * @return $this
  */
 public function view(View $view)
 {
     $this->markup .= $view->render();
     return $this;
 }
Exemplo n.º 8
0
 /**
  * Render the metabox.
  *
  * @param array    $fields
  * @param \WP_Post $post
  */
 protected function render(array $fields, $post)
 {
     $this->view->with(['__fields' => $fields, '__metabox' => $this, '__post' => $post]);
     echo $this->view->render();
 }
Exemplo n.º 9
0
 /**
  * @param string $view
  * @param array  $data
  *
  * @return string
  */
 public function render($view = NULL, array $data = []) : string
 {
     // merge existing scope with provided data array
     $this->merge($data);
     if (NULL === $view) {
         $view = $this->template;
     }
     // one way or the other, there must be a template to render
     if (NULL === $view) {
         throw new \InvalidArgumentException('No view template supplied.');
     }
     $path = $this->context->finder()->find($view);
     $blade_view = new View($this->context->factory(), $this->context->engine(), NULL, $path, $this->context->toArray());
     return $blade_view->render();
 }
Exemplo n.º 10
0
 /**
  * Triggered by the 'add_menu_page' or 'add_submenu_page'.
  */
 public function displayPage()
 {
     // Share the page instance to the view.
     $this->with('__page', $this);
     echo $this->view->render();
 }