namespace drunk . Template { import Cache = drunk . Cache ; import Promise = drunk . Promise ; let cacheStore = new Cache < any > ( 50 ) ; param urlOrId returns export function load ( urlOrId , useCache = true ) { var template = cacheStore . get ( urlOrId ) ; if ( template != null && useCache ) { return Promise . resolve ( template ) ; } var node = document . getElementById ( urlOrId ) ; if ( node && node . innerHTML ) { template = node . innerHTML ; cacheStore . set ( urlOrId , template ) ; return Promise . resolve ( template ) ; } var promise = util . ajax < string > ( { url : urlOrId } ) ; promise . done ( result => { cacheStore . set ( urlOrId , result ) ; } ) ; cacheStore . set ( urlOrId , promise ) ; return promise ; } }