Ferreteria/v0.5/layout/event: Difference between revisions
< Ferreteria | v0.5 | layout
Jump to navigation
Jump to search
(Created page with "==About== The '''layout''' system provides classes to encapsulate the rendering of serial-text output, working from the most general output concepts down to specific HTML tags...") |
No edit summary |
||
Line 5: | Line 5: | ||
==Methods== | ==Methods== | ||
===Events: general=== | ===Events: general=== | ||
* {{l/ver/meth|layout|ShouldDoTwigs}}: <syntaxhighlight lang=php inline>protected function ShouldDoTwigs() : bool</syntaxhighlight> | |||
** '''Action''': Determine whether events (including rendering) should be passed down to twigs. This typically returns a flag that is set during the calculations event. | |||
===Events: rendering=== | ===Events: rendering=== | ||
* {{l/ver/meth|layout|OnRender}}: <syntaxhighlight lang=php inline>public function OnRender(cEventNodeRender $oe) : void</syntaxhighlight> | * {{l/ver/meth|layout|OnRender}}: <syntaxhighlight lang=php inline>public function OnRender(cEventNodeRender $oe) : void</syntaxhighlight> | ||
** This is the optional dispatch method which the rendering event looks for. If present, it is called. | |||
* {{l/ver/meth|layout|RenderOutput}}: <syntaxhighlight lang=php inline>public function RenderOutput() : string</syntaxhighlight> | * {{l/ver/meth|layout|RenderOutput}}: <syntaxhighlight lang=php inline>public function RenderOutput() : string</syntaxhighlight> | ||
** '''Action''': Assemble the entirety of the object's output, including any twigs. | |||
* {{l/ver/meth|layout|RenderValue}}: <syntaxhighlight lang=php inline>protected function RenderValue() : string</syntaxhighlight> | * {{l/ver/meth|layout|RenderValue}}: <syntaxhighlight lang=php inline>protected function RenderValue() : string</syntaxhighlight> | ||
** '''Action''': Assemble the object's own output (separate from twig outputs). | |||
* {{l/ver/meth|layout|RenderBranch}}: <syntaxhighlight lang=php inline>protected function RenderBranch() : string</syntaxhighlight>: | * {{l/ver/meth|layout|RenderBranch}}: <syntaxhighlight lang=php inline>protected function RenderBranch() : string</syntaxhighlight>: | ||
** '''Action''': Assemble the twig outputs, applying any whole-list formatting (e.g. {{xml/tag|ul}}) or conditionals. | |||
* {{l/ver/meth|layout|RenderTwigs}}: <syntaxhighlight lang=php inline>protected function RenderTwigs() : string</syntaxhighlight> | * {{l/ver/meth|layout|RenderTwigs}}: <syntaxhighlight lang=php inline>protected function RenderTwigs() : string</syntaxhighlight> | ||
* {{l/ver/meth|layout| | ** '''Action''': Assemble the basic twig outputs, applying any list-item formatting (e.g. {{xml/tag|li}}. | ||
The canonical/typical method tree for rendering: | |||
* {{l/ver/meth|layout|OnRender}} calls: | |||
** {{l/ver/meth|layout|RenderOutput}} calls: | |||
*** {{l/ver/meth|layout|RenderValue}} | |||
*** {{l/ver/meth|layout|RenderBranch}} | |||
**** if {{l/ver/meth|layout|ShouldDoTwigs}}, calls {{l/ver/meth|layout|RenderTwigs}} | |||
This tree can be overridden at any point, but generally it's best to do so at the lowest level in order to cause the least disruption to offspring classes. |
Revision as of 13:23, 15 July 2022
About
The layout system provides classes to encapsulate the rendering of serial-text output, working from the most general output concepts down to specific HTML tags. It should be adaptable to other forms of markup.
The basic layout classes use the ferret\layout
namespace.
Methods
Events: general
- ShouldDoTwigs():
protected function ShouldDoTwigs() : bool
- Action: Determine whether events (including rendering) should be passed down to twigs. This typically returns a flag that is set during the calculations event.
Events: rendering
- OnRender():
public function OnRender(cEventNodeRender $oe) : void
- This is the optional dispatch method which the rendering event looks for. If present, it is called.
- RenderOutput():
public function RenderOutput() : string
- Action: Assemble the entirety of the object's output, including any twigs.
- RenderValue():
protected function RenderValue() : string
- Action: Assemble the object's own output (separate from twig outputs).
- RenderBranch():
protected function RenderBranch() : string
:- Action: Assemble the twig outputs, applying any whole-list formatting (e.g. <ul>) or conditionals.
- RenderTwigs():
protected function RenderTwigs() : string
- Action: Assemble the basic twig outputs, applying any list-item formatting (e.g. <li>.
The canonical/typical method tree for rendering:
- OnRender() calls:
- RenderOutput() calls:
- RenderValue()
- RenderBranch()
- if ShouldDoTwigs(), calls RenderTwigs()
- RenderOutput() calls:
This tree can be overridden at any point, but generally it's best to do so at the lowest level in order to cause the least disruption to offspring classes.