Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F75650
D7347.id16552.diff
All Users
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D7347.id16552.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -263,6 +263,7 @@
'PhutilRemarkupRuleMonospace' => 'markup/engine/remarkup/markuprule/PhutilRemarkupRuleMonospace.php',
'PhutilSafeHTML' => 'markup/PhutilSafeHTML.php',
'PhutilSafeHTMLProducerInterface' => 'markup/PhutilSafeHTMLProducerInterface.php',
+ 'PhutilSafeHTMLTestCase' => 'markup/__tests__/PhutilSafeHTMLTestCase.php',
'PhutilSaturateStdoutDaemon' => 'daemon/torture/PhutilSaturateStdoutDaemon.php',
'PhutilServiceProfiler' => 'serviceprofiler/PhutilServiceProfiler.php',
'PhutilShellLexer' => 'lexer/PhutilShellLexer.php',
@@ -605,6 +606,7 @@
'PhutilRemarkupRuleItalic' => 'PhutilRemarkupRule',
'PhutilRemarkupRuleLinebreaks' => 'PhutilRemarkupRule',
'PhutilRemarkupRuleMonospace' => 'PhutilRemarkupRule',
+ 'PhutilSafeHTMLTestCase' => 'PhutilTestCase',
'PhutilSaturateStdoutDaemon' => 'PhutilTortureTestDaemon',
'PhutilShellLexer' => 'PhutilLexer',
'PhutilShellLexerTestCase' => 'PhutilTestCase',
diff --git a/src/markup/PhutilSafeHTML.php b/src/markup/PhutilSafeHTML.php
--- a/src/markup/PhutilSafeHTML.php
+++ b/src/markup/PhutilSafeHTML.php
@@ -30,4 +30,15 @@
return new PhutilSafeHTML(call_user_func_array($function, $args));
}
+// Requires http://pecl.php.net/operator.
+
+ public function __concat($html) {
+ $clone = clone $this;
+ return $clone->appendHTML($html);
+ }
+
+ public function __assign_concat($html) {
+ return $this->appendHTML($html);
+ }
+
}
diff --git a/src/markup/__tests__/PhutilSafeHTMLTestCase.php b/src/markup/__tests__/PhutilSafeHTMLTestCase.php
new file mode 100644
--- /dev/null
+++ b/src/markup/__tests__/PhutilSafeHTMLTestCase.php
@@ -0,0 +1,22 @@
+<?php
+
+/**
+ * @group testcase
+ */
+final class PhutilSafeHTMLTestCase extends PhutilTestCase {
+
+ public function testOperator() {
+ if (!extension_loaded('operator')) {
+ $this->assertSkipped("Operator extension not available.");
+ }
+
+ $a = phutil_tag('a');
+ $ab = $a.phutil_tag('b');
+ $this->assertEqual('<a></a><b></b>', $ab->getHTMLContent());
+ $this->assertEqual('<a></a>', $a->getHTMLContent());
+
+ $a .= phutil_tag('a');
+ $this->assertEqual('<a></a><a></a>', $a->getHTMLContent());
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/x-diff
Storage Engine
amazon-s3
Storage Format
Raw Data
Storage Handle
phabricator/p2/46/wrqxvfkc2mtudepn
Default Alt Text
D7347.id16552.diff (2 KB)
Attached To
Mode
D7347: Allow concatenating HTML with operator extension
Attached
Detach File
Event Timeline
Log In to Comment