mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
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:
Vendored
+2
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user