mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-17 01:08:41 +01:00
Add renderHTMLView
Summary: - Implement AphrontView->renderHTMLView(), which works like AphrontView->renderSingleView() but always return PhutilSafeHTML. Test Plan: Action list view no longer as broken. Reviewers: vrana Reviewed By: vrana CC: aran Differential Revision: https://secure.phabricator.com/D4642
This commit is contained in:
parent
3093d1663d
commit
b9f394164f
3 changed files with 21 additions and 4 deletions
|
@ -50,6 +50,22 @@ abstract class AphrontView extends Phobject {
|
|||
}
|
||||
}
|
||||
|
||||
final protected function renderHTMLView($child) {
|
||||
if ($child instanceof AphrontView) {
|
||||
return phutil_safe_html($child->render());
|
||||
} else if ($child instanceof PhutilSafeHTML) {
|
||||
return $child;
|
||||
} else if (is_array($child)) {
|
||||
$out = array();
|
||||
foreach ($child as $element) {
|
||||
$out[] = $this->renderHTMLView($element);
|
||||
}
|
||||
return phutil_safe_html(implode('', $out));
|
||||
} else {
|
||||
return phutil_safe_html(phutil_escape_html($child));
|
||||
}
|
||||
}
|
||||
|
||||
abstract public function render();
|
||||
|
||||
}
|
||||
|
|
|
@ -36,12 +36,13 @@ final class PhabricatorActionListView extends AphrontView {
|
|||
}
|
||||
|
||||
require_celerity_resource('phabricator-action-list-view-css');
|
||||
return phutil_render_tag(
|
||||
|
||||
return phutil_tag(
|
||||
'ul',
|
||||
array(
|
||||
'class' => 'phabricator-action-list-view',
|
||||
),
|
||||
$this->renderSingleView($actions));
|
||||
$this->renderHTMLView($actions));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -39,12 +39,12 @@ final class PhabricatorHeaderView extends AphrontView {
|
|||
}
|
||||
|
||||
if ($this->tags) {
|
||||
$header[] = phutil_render_tag(
|
||||
$header[] = phutil_tag(
|
||||
'span',
|
||||
array(
|
||||
'class' => 'phabricator-header-tags',
|
||||
),
|
||||
self::renderSingleView($this->tags));
|
||||
$this->renderHTMLView($this->tags));
|
||||
}
|
||||
|
||||
return phutil_tag(
|
||||
|
|
Loading…
Add table
Reference in a new issue