summaryrefslogtreecommitdiff
path: root/app/View.php
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@gmail.com>2018-01-10 22:17:58 +0000
committerGreg Roach <fisharebest@gmail.com>2018-01-10 22:19:52 +0000
commitecf66805cdf435857ce4ed0eb577cfd1296f8989 (patch)
treeaad0d60c33499aac8e975e6bcbd30637929e8edc /app/View.php
parent11c27ebb1935d4a127a9929e8cae14878bc33bf0 (diff)
downloadwebtrees-ecf66805cdf435857ce4ed0eb577cfd1296f8989.tar.gz
webtrees-ecf66805cdf435857ce4ed0eb577cfd1296f8989.tar.bz2
webtrees-ecf66805cdf435857ce4ed0eb577cfd1296f8989.zip
Add laravel blade-style 'stacks' to views
Diffstat (limited to 'app/View.php')
-rw-r--r--app/View.php40
1 files changed, 40 insertions, 0 deletions
diff --git a/app/View.php b/app/View.php
index bc59ee1a8c..8d78b832ae 100644
--- a/app/View.php
+++ b/app/View.php
@@ -30,6 +30,16 @@ class View {
private $data;
/**
+ * @var string Implementation of Blade "stacks".
+ */
+ private static $stack;
+
+ /**
+ * @var array[] Implementation of Blade "stacks".
+ */
+ private static $stacks = [];
+
+ /**
* Createa view from a template name and optional data.
*
* @param $name
@@ -41,6 +51,36 @@ class View {
}
/**
+ * Implementation of Blade "stacks".
+ *
+ * @see https://laravel.com/docs/5.5/blade#stacks
+ */
+ public static function push(string $stack) {
+ self::$stack = $stack;
+ ob_start();
+ }
+
+ /**
+ * Implementation of Blade "stacks".
+ */
+ public static function endpush() {
+ self::$stacks[self::$stack][] = ob_get_clean();
+ }
+
+ /**
+ * Implementation of Blade "stacks".
+ *
+ * @return string
+ */
+ public static function stack(string $stack): string {
+ $content = implode('', self::$stacks[$stack] ?? []);
+
+ self::$stacks[$stack] = [];
+
+ return $content;
+ }
+
+ /**
* Render a view.
*
* @return string