2019-12-29 22:31:32 +00:00
|
|
|
import * as renderUtils from './render-utils';
|
|
|
|
|
import HoganJsUtils from './hoganjs-utils';
|
|
|
|
|
import { DiffFile } from './types';
|
2019-10-12 21:45:49 +00:00
|
|
|
|
2019-12-29 22:31:32 +00:00
|
|
|
const baseTemplatesPath = 'file-summary';
|
|
|
|
|
const iconsBaseTemplatesPath = 'icon';
|
2019-10-12 21:45:49 +00:00
|
|
|
|
2019-10-21 22:37:42 +00:00
|
|
|
export function render(diffFiles: DiffFile[], hoganUtils: HoganJsUtils): string {
|
2019-10-12 21:45:49 +00:00
|
|
|
const files = diffFiles
|
|
|
|
|
.map(file =>
|
|
|
|
|
hoganUtils.render(
|
|
|
|
|
baseTemplatesPath,
|
2019-12-29 22:31:32 +00:00
|
|
|
'line',
|
2019-10-12 21:45:49 +00:00
|
|
|
{
|
|
|
|
|
fileHtmlId: renderUtils.getHtmlId(file),
|
|
|
|
|
oldName: file.oldName,
|
|
|
|
|
newName: file.newName,
|
|
|
|
|
fileName: renderUtils.filenameDiff(file),
|
2019-12-29 22:31:32 +00:00
|
|
|
deletedLines: '-' + file.deletedLines,
|
|
|
|
|
addedLines: '+' + file.addedLines,
|
2019-10-12 21:45:49 +00:00
|
|
|
},
|
|
|
|
|
{
|
2019-12-29 22:31:32 +00:00
|
|
|
fileIcon: hoganUtils.template(iconsBaseTemplatesPath, renderUtils.getFileIcon(file)),
|
|
|
|
|
},
|
|
|
|
|
),
|
2019-10-12 21:45:49 +00:00
|
|
|
)
|
2019-12-29 22:31:32 +00:00
|
|
|
.join('\n');
|
2019-10-12 21:45:49 +00:00
|
|
|
|
2019-12-29 22:31:32 +00:00
|
|
|
return hoganUtils.render(baseTemplatesPath, 'wrapper', {
|
2019-10-12 21:45:49 +00:00
|
|
|
filesNumber: diffFiles.length,
|
2019-12-29 22:31:32 +00:00
|
|
|
files: files,
|
2019-10-12 21:45:49 +00:00
|
|
|
});
|
|
|
|
|
}
|