"use strict";
const util = require("util");
class MicroTemplateService {
    constructor($dynamicHelpService, $injector) {
        this.$dynamicHelpService = $dynamicHelpService;
        this.$injector = $injector;
        this.dynamicCallRegex = new RegExp(util.format("(%s)", this.$injector.dynamicCallRegex.source), "g");
    }
    parseContent(data, options) {
        let localVariables = this.$dynamicHelpService.getLocalVariables(options).wait();
        let compiledTemplate = _.template(data.replace(this.dynamicCallRegex, "this.$injector.dynamicCall(\"$1\").wait()"));
        return compiledTemplate.apply(this, [localVariables]);
    }
}
exports.MicroTemplateService = MicroTemplateService;
$injector.register("microTemplateService", MicroTemplateService);
