bond(). The
first argument of this directive is used to call a bond component controller from the spoova/mi/windows/Bond namespace. Once called,
the bond component controller will determine how bond components are rendered into the webpage. Bond componnents are added separately into a reserved
directory "windows/Rex/Bond" where they can be rendered before being added to the web page. The main feature of bond component is that they have
extended functionality of rendering live templates using bond live template attributes.
@load('bond') directive. This will include the bond script into the template file and we can
start to work with bond components. A sample is shown below
@template('sample')
@load('bond')
@template;
@template directive
loads an external template, the @load directive will load the bond scripts
into the template file. Once we load the bond script, we can then continue with initializing the bond
components.
bond() to the rex template file similarly as below:
bond('Posts')
namespace spoova/mi/windows/Bond;
use spoova/mi/core/classes/Bond;
class Posts extends Bond{
public function render(): Compiler|String {
return <<<compile
<div>Hello World!</div>
compile;
}
}
bond('Posts') to our template file. The
directive will in turn call the bond component controller spoova/mi/windows/Bond/Posts. This will render the page
and return the text "Hello world!" .
<php?
namespace spoova/mi/windows/Bond;
use spoova/mi/core/classes/Bond;
class Posts extends Bond{
function render() : Compiler|String {
return compile('bond.template_path');
}
}
<div>
Hello world!
</div>
windows/Rex
directory so as to prevent conflicting of files and to make it easier to locate them. Also, all bond component must have a root element