mirror of
https://github.com/Mibew/CanteenHTML5.git
synced 2025-02-05 13:34:42 +03:00
Add untagged container
This commit is contained in:
parent
047273e3b8
commit
c15142fdd8
44
src/Fragment.php
Normal file
44
src/Fragment.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @module Canteen\HTML5
|
||||
*/
|
||||
namespace Canteen\HTML5
|
||||
{
|
||||
/**
|
||||
* Represents a set of HTML tags without a wrapper.
|
||||
* Do not initiate this class directly, use the `html()` function:
|
||||
*
|
||||
* $div = html('container');
|
||||
*
|
||||
* @class UntaggedContainer
|
||||
* @extends Node
|
||||
* @constructor
|
||||
* @param {Node|Array} [children=null] The collection of children or single child
|
||||
*/
|
||||
class Fragment extends NodeContainer
|
||||
{
|
||||
public function __construct($children = null)
|
||||
{
|
||||
parent::__construct('fragment', $children, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write to HTML
|
||||
* @method __toString
|
||||
* @return {String} The string representation of this HTML node
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
$buffer = '';
|
||||
foreach($this->getChildren() as $child)
|
||||
{
|
||||
$buffer .= $child->__toString();
|
||||
}
|
||||
|
||||
return $buffer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -109,6 +109,11 @@ namespace Canteen\HTML5
|
||||
{
|
||||
return new Text($childrenOrAttributes);
|
||||
}
|
||||
// Untagged container
|
||||
else if ($tag == 'fragment')
|
||||
{
|
||||
return new Fragment($childrenOrAttributes);
|
||||
}
|
||||
// Check for task specification
|
||||
else if (isset(Specification::$TAGS[$tag]))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user