Skip to content

Commit a8ccfc6

Browse files
committed
Added ability to set title for SideBySide renderer
1 parent 1e88465 commit a8ccfc6

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# [2.0.4](https://github.com/phalcongelist/php-diff/releases/tag/v2.0.4) (2016-XX-XX)
2+
3+
* Added ability to set title for `SideBySide` renderer
4+
15
# [2.0.3](https://github.com/phalcongelist/php-diff/releases/tag/v2.0.3) (2016-07-18)
26

37
* Fixed `BaseArray` class name

src/Diff/Renderer/Html/SideBySide.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
*/
2626
class SideBySide extends BaseArray
2727
{
28+
private $oldTitle = 'Old Version';
29+
private $newTitle = 'New Version';
30+
2831
/**
2932
* Render a and return diff with changes between the two sequences
3033
* displayed side by side.
@@ -40,11 +43,19 @@ public function render()
4043
return $html;
4144
}
4245

46+
if (isset($this->options['oldTitle'])) {
47+
$this->oldTitle = $this->options['oldTitle'];
48+
}
49+
50+
if (isset($this->options['newTitle'])) {
51+
$this->newTitle = $this->options['newTitle'];
52+
}
53+
4354
$html .= '<table class="Differences DifferencesSideBySide">';
4455
$html .= '<thead>';
4556
$html .= '<tr>';
46-
$html .= '<th colspan="2">Old Version</th>';
47-
$html .= '<th colspan="2">New Version</th>';
57+
$html .= '<th colspan="2">' . $this->oldTitle . '</th>';
58+
$html .= '<th colspan="2">' . $this->newTitle . '</th>';
4859
$html .= '</tr>';
4960
$html .= '</thead>';
5061

0 commit comments

Comments
 (0)