From 988df7b7f4685d24359db8cfdc9542fb29e6c53c Mon Sep 17 00:00:00 2001 From: Peter Palotas Date: Sun, 28 Dec 2014 19:58:37 +0100 Subject: [PATCH] - Added documentation to Marionette.TemplateCache. Added strong types for parameters and return types of this class. --- marionette/marionette.d.ts | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/marionette/marionette.d.ts b/marionette/marionette.d.ts index e12a553b9..6479f0f38 100644 --- a/marionette/marionette.d.ts +++ b/marionette/marionette.d.ts @@ -564,12 +564,39 @@ declare module Marionette { without(...values: any[]): Region[]; } + /** + * The TemplateCache provides a cache for retrieving templates from script blocks + * in your HTML. This will improve the speed of subsequent calls to get a template. + */ class TemplateCache { - static get (templateId): any; - static clear(): void; + /** + * To use the TemplateCache, call the get method on TemplateCache directly. Internally, instances of the TemplateCache class will be created and stored but you do not have to manually create these instances yourself. get will return a compiled template function. + */ + static get(templateId: string): any; - loadTemplate(templateId): any; - compileTemplate(rawTemplate): any; + /** + * You can clear one or more, or all items from the cache using the clear + * method. Clearing a template from the cache will force it to re-load + * from the DOM the next time it is retrieved. + * @param the templateId used for loading / caching of the templates to clear. If none specified, all templates will be cleared from the cache. + */ + static clear(...templateId: string[]): void; + + /** + * The default template retrieval is to select the template contents from the + * DOM using jQuery. If you wish to change the way this works, you can + * override this method on the TemplateCache object. + */ + loadTemplate(templateId: string): any; + + /** + * he default template compilation passes the results from loadTemplate to + * the compileTemplate function, which returns an underscore.js compiled + * template function. When overriding compileTemplate remember that it + * must return a function which takes an object of parameters and values + * and returns a formatted HTML string. + */ + compileTemplate(rawTemplate: any): any; } class Renderer {