9108d3523d
XML comment syntax for XHP is one of the top wishlist items within the UIE group (+ some other people).
Currently, the only way to have comments inside XHP blocks is to use expressions and block comments, e.g.
<div>{/* comment */}</div>
After this change, you can use the more familiar syntax. This syntax is limited to XHP child contexts:
// Only single-line, doc, block comments work outside XHP
$xhp =
<div>
<!--XML comments only work within XHP children contexts-->
</div>;
Based on http://www.w3.org/TR/REC-xml/#sec-comments - except we ignore the rule about double hyphens ('--') within a comment because we don't care about SGML.
43 linhas
626 B
PHP
43 linhas
626 B
PHP
<?php
|
|
|
|
class :node {
|
|
private $children;
|
|
public function __construct($_, $children) {
|
|
$this->children = $children;
|
|
}
|
|
public function __toString() {
|
|
$o = '';
|
|
foreach ($this->children as $child) {
|
|
$o .= (string)$child;
|
|
}
|
|
$o .= count($this->children);
|
|
return $o;
|
|
}
|
|
}
|
|
|
|
$n1 =
|
|
<node>
|
|
<!--hey-->
|
|
</node>;
|
|
|
|
$n2 =
|
|
<node>
|
|
{'a'}
|
|
<!--hey-->
|
|
<!--
|
|
multiline comment
|
|
with multiple lines
|
|
-->
|
|
{'b'}
|
|
<node>
|
|
{'c'}
|
|
<!--nested comment-->
|
|
</node>
|
|
<!--comment-with -- extra--hyphens----->
|
|
</node>;
|
|
|
|
echo
|
|
(string)$n1.
|
|
(string)$n2.
|
|
"\n";
|