You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[`TViewPartial`](https://github.com/fanoframework/fano/blob/master/src/Mvc/Views/ViewPartialImpl.pas), this class loads template from file, replace any variable placeholders and output it as string.
474
488
-[`TStrViewPartial`](https://github.com/fanoframework/fano/blob/master/src/Mvc/Views/StrViewPartialImpl.pas), it is similar as above but loads template from string.
475
489
490
+
## Compose view using view stack
491
+
492
+
View stack is similar to view partial except that you can push string as many as you need and view stack will concat and render pushed string. It is inspired by Laravel Blade `@stack` and `@push` directive. However, in Fano Framework, we use `IViewStack` and `IViewPush` interface.
493
+
494
+
To explain view stack, let use `TBaseTemplate` class in example above
495
+
496
+
```
497
+
TBaseTemplate = class abstract (TInterfacedObject, IView)
498
+
private
499
+
fViewStack : IViewStack;
500
+
protected
501
+
fViewPush : IViewPush;
502
+
function pageTitle() : string; virtual; abstract;
503
+
function headCss() : string; virtual; abstract;
504
+
function scriptJs() : string; virtual; abstract;
505
+
function mainContent() : string; virtual; abstract;
Please note that now we have view stack created and we setup `js` name where any pushed string will go. Let us use example `THomeTemplate` class above and use view push instance
While many built-in implementations of `IView` interface are related to HTML presentation, you can use it to generate other presentation such as JSON or PDF document.
0 commit comments