How to use the botbuilder-lg.TemplateEngine function in botbuilder-lg

To help you get started, we’ve selected a few botbuilder-lg examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / botbuilder-tools / packages / LGvscodeExt / src / providers / templateEngineParser.ts View on Github external
function updateTemplateEngine(uri: vscode.Uri) {
    let engine: TemplateEngine = new TemplateEngine();

    try {
        engine = engine.addFile(uri.fsPath);
    }
    catch(e)
    {
        // ignore it
        //vscode.window.showWarningMessage(e.message);
    }

    DataStorage.templateEngineMap.set(uri.fsPath, new TemplateEngineEntity(uri, engine));
}
github microsoft / botbuilder-js / libraries / botbuilder-dialogs-adaptive / src / generators / templateEngineLanguageGenerator.ts View on Github external
private initTemplateEngine(turnContext: TurnContext): TemplateEngine {
        const locale = turnContext.activity.locale? turnContext.activity.locale.toLocaleLowerCase() : '';
        if (this.multiLangEngines.size > 0) {
            const fallbackLocale = MultiLanguageResourceLoader.fallbackLocale(locale.toLocaleLowerCase(), Array.from(this.multiLangEngines.keys()));
            this.engine = this.multiLangEngines.get(fallbackLocale);
        } else {
            this.engine = this.engine? this.engine : new TemplateEngine();
        }

        return this.engine;
    }
}
github microsoft / botbuilder-js / libraries / botbuilder-dialogs-adaptive / src / generators / templateEngineLanguageGenerator.ts View on Github external
public constructor(lgText?: string | TemplateEngine, id?: string, resourceMapping?: Map) {
        if (typeof lgText === 'string' && id !== undefined && resourceMapping !== undefined) {
            this.id = id !== undefined? id : this.DEFAULTLABEL;
            const {prefix: _, language: locale} = MultiLanguageResourceLoader.parseLGFileName(id);
            const fallbackLocale: string = MultiLanguageResourceLoader.fallbackLocale(locale.toLocaleLowerCase(), Array.from(resourceMapping.keys()));
            for (const mappingKey of resourceMapping.keys()) {
                if (fallbackLocale === ''  || fallbackLocale === mappingKey) {
                    const engine = new TemplateEngine().addText(lgText !== undefined? lgText : '', id, LanguageGeneratorManager.resourceExplorerResolver(mappingKey, resourceMapping));
                    this.multiLangEngines.set(mappingKey, engine);
                }
            }
        } else if (lgText instanceof TemplateEngine) {
            this.engine = lgText;
        } else {
            this.engine = new TemplateEngine();
        }
    }
github microsoft / botbuilder-js / libraries / botbuilder-dialogs-adaptive / src / generators / templateEngineLanguageGenerator.ts View on Github external
public constructor(lgText?: string | TemplateEngine, id?: string, resourceMapping?: Map) {
        if (typeof lgText === 'string' && id !== undefined && resourceMapping !== undefined) {
            this.id = id !== undefined? id : this.DEFAULTLABEL;
            const {prefix: _, language: locale} = MultiLanguageResourceLoader.parseLGFileName(id);
            const fallbackLocale: string = MultiLanguageResourceLoader.fallbackLocale(locale.toLocaleLowerCase(), Array.from(resourceMapping.keys()));
            for (const mappingKey of resourceMapping.keys()) {
                if (fallbackLocale === ''  || fallbackLocale === mappingKey) {
                    const engine = new TemplateEngine().addText(lgText !== undefined? lgText : '', id, LanguageGeneratorManager.resourceExplorerResolver(mappingKey, resourceMapping));
                    this.multiLangEngines.set(mappingKey, engine);
                }
            }
        } else if (lgText instanceof TemplateEngine) {
            this.engine = lgText;
        } else {
            this.engine = new TemplateEngine();
        }
    }