Skip to content

Commit

Permalink
Merge pull request #35 from WebFiori/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
usernane authored May 17, 2023
2 parents 291f1aa + 119f82a commit 5b0a0b4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@ A set of classes that provide basic web pages creation utilities in addition to
| <a target="_blank" href="https://github.com/WebFiori/ui/actions/workflows/php82.yml"><img src="https://github.com/WebFiori/ui/workflows/Build%20PHP%208.2/badge.svg?branch=master"></a> |

## Features
* Ability to create custom HTML UI Elements as PHP classes or PHP templates.
* 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

Expand Down
2 changes: 1 addition & 1 deletion tests/webfiori/test/ui/HTMLNodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ public function testFromHTML_00() {
*/
public function testFromHTML_01() {
$htmlTxt = '';
$val = TemplateCompiler::fromHTMLText($htmlTxt);
$val = HTMLNode::fromHTML($htmlTxt);
$this->assertNull($val);
}
/**
Expand Down
26 changes: 25 additions & 1 deletion webfiori/ui/HTMLNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <b>$asHTMLDocObj</b> is set to 'true', an object of type
* 'HTMLDoc' is returned. If the given code has multiple top level nodes
* (e.g. '&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;'),
* 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.
*
Expand Down
1 change: 0 additions & 1 deletion webfiori/ui/TemplateCompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 5b0a0b4

Please sign in to comment.