twig: Added overload to Template.render when allow_async=false (#42593)

* Added overload to twig Template.render when allow_async=false

* twig: added test to demonstrate behavior with allow_async

* twig: added test with unknown boolean

* twig: fixed whitespace
This commit is contained in:
Daniel Melcer
2020-02-25 12:58:13 -08:00
committed by GitHub
parent 8fb86da992
commit b2ff010b24
2 changed files with 13 additions and 0 deletions
+2
View File
@@ -3,6 +3,7 @@
// Definitions by: Carlos Ballesteros Velasco <https://github.com/soywiz>
// Tim Schumacher <https://github.com/enko>
// Maik Tizziani <https://github.com/mtizziani>
// Daniel Melcer <https://github.com/dmelcer9>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Imported from: https://github.com/soywiz/typescript-node-definitions/twig.d.ts
@@ -24,6 +25,7 @@ export interface Parameters {
export interface Template {
reset(blocks: any): void;
render(context?: any, params?: any, allow_async?: false): string;
render(context?: any, params?: any, allow_async?: boolean): string | Promise<string>;
renderAsync(context?: any, params?: any): Promise<string>;
importFile(file: string): Template;
+11
View File
@@ -20,6 +20,17 @@ const params: twig.Parameters = {
const temp: twig.Template = twig.twig(params);
const result: string = temp.render();
const async_result: string | Promise<string> = temp.render(undefined, undefined, true);
function twig_async_param(b: boolean) {
const maybe_async_result: string | Promise<string> = temp.render(undefined, undefined, b);
}
twig_async_param(true);
twig_async_param(false);
const compOpts: twig.CompileOptions = {
filename: str,
settings: value