UNPKG

534 BPlain TextView Raw
1import { IHtmlEngineHelper } from './html-engine-helper.interface';
2import * as Handlebars from 'handlebars';
3
4export class BreakLinesHelper implements IHtmlEngineHelper {
5 constructor(private bars) {}
6
7 public helperFunc(context: any, text: string) {
8 text = this.bars.Utils.escapeExpression(text);
9 text = text.replace(/(\r\n|\n|\r)/gm, '<br>');
10 text = text.replace(/ /gm, '&nbsp;');
11 text = text.replace(/ /gm, '&nbsp;&nbsp;&nbsp;&nbsp;');
12 return new Handlebars.SafeString(text);
13 }
14}