1414</p >
1515
1616## About
17- PHPMarkup is a markup processor based on the [ LHTML ] ( https://github.com/Ouxsoft/LHTML ) standard written in PHP.
17+ PHPMarkup is a lightweight markup processor standard written in PHP.
1818It facilitates the extraction of markup into a data structure, orchestrated manipulation of said structure, and output as
19- (optimized) markup.
19+ (optimized) markup and uses the [ LHTML ] ( https://github.com/Ouxsoft/LHTML ) standard .
2020
2121### Instructions
2222Create a PHPMarkup Element to instruct DOMElement processing.
2323``` php
2424/**
25- * Class SayHello
26- * DomElement process class
25+ * Class MessagesElement
2726 */
28- class SayHello extends Ouxsoft\PHPMarkup\Element
27+ class MessagesElement extends Ouxsoft\PHPMarkup\Element
2928{
30- /**
31- * @return string
32- */
29+ private $messages;
30+
31+ public function onLoad() : void
32+ {
33+ $this->messages = $this->db->query('SELECT `msg` FROM `messages`;');
34+ }
35+
3336 public function onRender(): string
3437 {
35- return 'Hello, ' . $this->getArgByName('who') . $this->innerText();
38+ $out = '';
39+ foreach($this->messages as $row){
40+ $out .= $row['msg'] . $this->getArgByName('delimiter');
41+ }
42+ return $out;
3643 }
3744}
3845```
@@ -42,18 +49,17 @@ Process a DOM using the class created.
4249``` php
4350use Ouxsoft\PHPMarkup\Factory\ProcessorFactory;
4451
45- // Instantiate Processor and configure to parse output buffer
4652$processor = ProcessorFactory::getInstance();
47- $processor->addElement(['xpath' => '//greetings', 'class_name' => 'SayHello']);
53+ $processor->addElement(['xpath' => '//messages', 'class_name' => 'MessagesElement']);
54+ $processor->addRoutine(['method' => 'onLoad']);
4855$processor->addRoutine(['method' => 'onRender', 'execute' => 'RETURN_CALL']);
56+ $processor->addProperty('db', new PDO('sqlite:/example.db'));
4957$processor->parseBuffer();
50-
51- // Displays "Hello, World!" when rendered by Browser
5258?>
5359<html lang =" en" >
54- <greetings >
55- <arg name =" who " >World </arg >!
56- </greetings >
60+ <messages >
61+ <arg name =" delimiter " >; </arg >
62+ </messages >
5763</html >
5864```
5965
0 commit comments