From 49f1683b13e4a4a6cecf14651ba8911383b1619e Mon Sep 17 00:00:00 2001 From: Ibrahim Date: Wed, 17 May 2023 13:17:13 +0300 Subject: [PATCH 1/4] Update TemplateCompiler.php --- webfiori/ui/TemplateCompiler.php | 1 - 1 file changed, 1 deletion(-) diff --git a/webfiori/ui/TemplateCompiler.php b/webfiori/ui/TemplateCompiler.php index 6250a93..9fcc1e1 100644 --- a/webfiori/ui/TemplateCompiler.php +++ b/webfiori/ui/TemplateCompiler.php @@ -132,7 +132,6 @@ public function compile(array $varsToPass = []) { * is a subclass of the class 'HTMLNode'. * * @throws InvalidNodeNameException - * @since 1.7.4 */ public static function fromHTMLText(string $text, bool $asHTMLDocObj = true) { $nodesArr = self::htmlAsArray($text); From 4a292724a33ba4f1cd1b120ceae84aa1af159464 Mon Sep 17 00:00:00 2001 From: Ibrahim Date: Wed, 17 May 2023 13:17:21 +0300 Subject: [PATCH 2/4] Update HTMLNode.php --- webfiori/ui/HTMLNode.php | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/webfiori/ui/HTMLNode.php b/webfiori/ui/HTMLNode.php index ef064e8..667bc2a 100644 --- a/webfiori/ui/HTMLNode.php +++ b/webfiori/ui/HTMLNode.php @@ -829,7 +829,31 @@ public static function fromFile(string $absPath, array $slotsOrVars = []) { return $compiler->getCompiled(); } - + /** + * Creates HTMLNode object given a string of HTML code. + * + * Note that this method is still under implementation. + * + * @param string $htmlTxt A string that represents HTML code. + * + * @param bool $asHTMLDocObj If set to 'true' and given HTML represents a + * structured HTML document, the method will convert the code to an object + * of type 'HTMLDoc'. Default is 'true'. + * + * @return array|HeadNode|HTMLDoc|HTMLNode If the given code represents HTML document + * and the parameter $asHTMLDocObj is set to 'true', an object of type + * 'HTMLDoc' is returned. If the given code has multiple top level nodes + * (e.g. '<div></div><div></div>'), + * an array that contains an objects of type 'HTMLNode' is returned. If the + * given code has one top level node, an object of type 'HTMLNode' is returned. + * Note that it is possible that the method will return an instance which + * is a subclass of the class 'HTMLNode'. + * + * @throws InvalidNodeNameException + */ + public static function fromHTML(string $htmlTxt, bool $asHTMLDocObj = true) { + return TemplateCompiler::fromHTMLText($htmlTxt, $asHTMLDocObj); + } /** * Returns the value of an attribute. * From f65ded468f220b261a7107d289c1a448163839be Mon Sep 17 00:00:00 2001 From: Ibrahim Date: Wed, 17 May 2023 13:17:25 +0300 Subject: [PATCH 3/4] Update HTMLNodeTest.php --- tests/webfiori/test/ui/HTMLNodeTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/webfiori/test/ui/HTMLNodeTest.php b/tests/webfiori/test/ui/HTMLNodeTest.php index f82a6e8..059f17c 100644 --- a/tests/webfiori/test/ui/HTMLNodeTest.php +++ b/tests/webfiori/test/ui/HTMLNodeTest.php @@ -721,7 +721,7 @@ public function testFromHTML_00() { */ public function testFromHTML_01() { $htmlTxt = ''; - $val = TemplateCompiler::fromHTMLText($htmlTxt); + $val = HTMLNode::fromHTML($htmlTxt); $this->assertNull($val); } /** From 7111f4836d568eeb00cb47f79a8ae4fb976c8626 Mon Sep 17 00:00:00 2001 From: Ibrahim BinAlshikh Date: Wed, 17 May 2023 13:21:33 +0300 Subject: [PATCH 4/4] Update README.md --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 16a1910..4e5678f 100644 --- a/README.md +++ b/README.md @@ -36,11 +36,10 @@ This library is a part of WebFior | | ## Features -* Ability to create custom HTML UI Elements. -* OPP abstraction to create and modify DOM through PHP. +* Ability to create custom HTML UI Elements in OOP approach. +* Virtual DOM through PHP. * Building dynamic HTML templates with PHP. -* Provides a basic templating engine. -* Support for creating XML documents. +* Support for rendering XML documents. ## Usage For more information on how to use the library, [check here](https://webfiori.com/learn/ui-package)