##// END OF EJS Templates
added provided and configure methods to the fluent container configuration, added applyConfig method to the container
added provided and configure methods to the fluent container configuration, added applyConfig method to the container

File last commit:

r115:691199f665e0 ioc ts support
r142:be7edf08a115 v1.4.0-rc3 default
Show More
template-compile.ts
49 lines | 1.3 KiB | video/mp2t | TypeScriptLexer
/ src / amd / ts / text / template-compile.ts
cin
text/template-compile ported to typescript
r56 import request = require("dojo/request");
import m = require("module");
import { TraceSource } from "../log/TraceSource";
import { TemplateCompiler } from "./TemplateCompiler";
import { TemplateParser } from "./TemplateParser";
import { isNullOrEmptyString } from "../safe";
import { MapOf } from "../interfaces";
type TemplateFn = (obj: object) => string;
const trace = TraceSource.get(m.id);
function compile(str: string) {
if (isNullOrEmptyString(str))
return () => "";
const parser = new TemplateParser(str);
const compiler = new TemplateCompiler();
return compiler.compile(parser);
}
const cache: MapOf<TemplateFn> = {};
interface OnLoadFn<T> {
(res: T): void;
error(e: any): void;
}
compile.load = (id: string, require: Require, callback: OnLoadFn<TemplateFn>) => {
const url = require.toUrl(id);
if (url in cache) {
trace.debug("{0} -> {1}: cached", id, url);
callback(cache[url]);
} else {
trace.debug("{0} -> {1}: load", id, url);
cin
corrected code to support ts strict mode...
r115 request<string>(url).then(compile).then((tc: TemplateFn) => {
cin
text/template-compile ported to typescript
r56 trace.debug("{0}: compiled", url);
callback(cache[url] = tc);
}, (err: any) => {
callback.error({
inner: err,
src: "@implab/core/text/template-compile"
});
});
}
};
export = compile;