-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(preview): add isolated (iframe) mod support for preview area
- Loading branch information
Showing
4 changed files
with
118 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import {format} from '@exadel/esl/modules/esl-utils/misc'; | ||
|
||
interface UIPRenderingTemplateParams { | ||
title?: string; | ||
content: string; | ||
[additional: string]: string | number | boolean | undefined | null; | ||
} | ||
|
||
export class UIPRenderingTemplatesService { | ||
/** Template storage */ | ||
protected static templates = new Map<string, string>(); | ||
|
||
/** Register template */ | ||
public static add(name: string, template: string): void { | ||
this.templates.set(name, template); | ||
} | ||
/** Get template */ | ||
public static get(name: string): string | undefined { | ||
return this.templates.get(name); | ||
} | ||
|
||
/** Render template */ | ||
public static render(name: string, params: UIPRenderingTemplateParams): string { | ||
const template = this.get(name); | ||
if (!template) return params.content; | ||
return format(template, params); | ||
} | ||
} | ||
|
||
UIPRenderingTemplatesService.add('default', ` | ||
<html> | ||
<head> | ||
<title>{title}</title> | ||
</head> | ||
<body> | ||
{content} | ||
</body> | ||
</html> | ||
`); |