-
-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9c6e884
commit baee787
Showing
2 changed files
with
33 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,15 +84,33 @@ export interface RenderOptions { | |
Renders the provided template and appends it to the DOM. | ||
@public | ||
@param {CompiledTemplate} template the template to render | ||
@param {TemplateFactory | unknown} renderable the template or component to render | ||
@param {RenderOptions} options options hash containing engine owner ({ owner: engineOwner }) | ||
@returns {Promise<void>} resolves when settled | ||
*/ | ||
export function render( | ||
template: TemplateFactory, | ||
renderable: TemplateFactory | unknown, | ||
options?: RenderOptions | ||
): Promise<void> { | ||
let context = getContext(); | ||
let template: TemplateFactory; | ||
|
||
if ( | ||
typeof renderable === 'function' && | ||
renderable.name === 'factory' && | ||
'__meta' in renderable | ||
) { | ||
template = renderable as TemplateFactory; | ||
} else { | ||
// NOTE: this only works with [email protected]+ | ||
if (!context) { | ||
throw new Error( | ||
'cannot render strict mode templates outside of a test context' | ||
); | ||
} | ||
context.setProperties({ __renderable__: renderable }); | ||
template = hbs`<this.__renderable__ />`; | ||
} | ||
|
||
if (!template) { | ||
throw new Error('you must pass a template to `render()`'); | ||
|
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