fast framework Help

Presenter nesting and componentisation

Fast framework supports presenter nesting directly in HTML markup, in a similar way to how current major front-end frameworks allow component nesting with JSX.

This allows for componentisation of presenters and controlling their logic when nested within other presenters.

file presenters/myButton.html

<button>I'm a button</button>

file presenters/myPresenter.html

<section> <h1>Hello, World</h1> <myButton/> </section>

myPresenter will then output the following html:

<section> <h1>Hello, World</h1> <button>I'm a button</button> </section>

properties

By default, globally defined settings (as described in Settings, Properties and the Cascade) of the host presenter will automatically be passed to the nested presenter.

To allow for more specific and ephemeral configuration of the nested presenter, arbitrary properties can be explicitly passed in the markup that then can be processed further by the presenter's code:

file presenters/myPresenter.html

<section> <h1>Hello, World</h1> <myButton type="primary"/> <myButton type="secondary"/> </section>

file presenters/myButton.php

<?php class myButton extends ffPresenter{ public string $type; public function output(){ if(!empty($this->type)){ // internal logic based on type property } return parent::output(); } }

If the presenter class defines a public property with the same name as an HTML attribute, the value of the attribute will be set directly.

If you need more control over how the property is processed, you can create a setter method that matches the "set + property name in capital case" pattern. (e.g. setType() to set the $type property).:

file presenters/myButton.php

<?php class myButton extends ffPresenter{ private $type = ''; public function setType(string $type){ // process input before setting it } public function output(){ if(!empty($this->type)){ // internal logic based on type property } return parent::output(); } }
09 Juni 2025