All files / src template.ts

25% Statements 2/8
100% Branches 0/0
0% Functions 0/5
25% Lines 2/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33  2x                                                           2x  
import Node from 'type/node';
import standardizeIndentation from 'template/utility/standardize-indentation';
 
abstract class Template<Input> {
	private input: Input;
 
	public constructor(input: Input) {
		this.input = input;
	}
 
	public render(): string {
		const html = this.getHtml();
 
		return standardizeIndentation(html);
	}
 
	protected getInput(): Input {
		return this.input;
	}
 
	protected buildNodeUrl(node: Node): string {
		return this.buildUrl(node.type_id, node.id);
	}
 
	protected buildUrl(type_id: string, node_id: string): string {
		return `/${type_id}/${node_id}`;
	}
 
	protected abstract getHtml(): string;
}
 
export default Template;