Package play.templates
Class TemplateLoader
- java.lang.Object
-
- play.templates.TemplateLoader
-
public class TemplateLoader extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.util.Map<java.lang.String,BaseTemplate>templates
-
Constructor Summary
Constructors Constructor Description TemplateLoader()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcleanCompiledCache()Cleans the cache for all templatesstatic voidcleanCompiledCache(java.lang.String key)Cleans the specified key from the cachestatic java.util.List<Template>getAllTemplate()List all found templatesstatic java.lang.StringgetUniqueNumberForTemplateFile(java.lang.String path)All loaded templates is cached in the templates-list using a key.static Templateload(java.lang.String path)Load a templatestatic BaseTemplateload(java.lang.String key, java.lang.String source)Load a template from a Stringstatic BaseTemplateload(java.lang.String key, java.lang.String source, boolean reload)Clean the cache for that key Then load a template from a Stringstatic Templateload(VirtualFile file)Load a template from a virtual filestatic BaseTemplateloadString(java.lang.String source)Load template from a String, but don't cache it
-
-
-
Field Detail
-
templates
protected static java.util.Map<java.lang.String,BaseTemplate> templates
-
-
Method Detail
-
getUniqueNumberForTemplateFile
public static java.lang.String getUniqueNumberForTemplateFile(java.lang.String path)
All loaded templates is cached in the templates-list using a key. This key is included as part of the classname for the generated class for a specific template. The key is included in the classname to make it possible to resolve the original template-file from the classname, when creating cleanStackTrace This method returns a unique representation of the path which is usable as part of a classname- Parameters:
path- Path of the template file- Returns:
- a unique representation of the path which is usable as part of a classname
-
load
public static Template load(VirtualFile file)
Load a template from a virtual file- Parameters:
file- A VirtualFile- Returns:
- The executable template
-
load
public static BaseTemplate load(java.lang.String key, java.lang.String source)
Load a template from a String- Parameters:
key- A unique identifier for the template, used for retrieving a cached templatesource- The template source- Returns:
- A Template
-
load
public static BaseTemplate load(java.lang.String key, java.lang.String source, boolean reload)
Clean the cache for that key Then load a template from a String- Parameters:
key- A unique identifier for the template, used for retrieving a cached templatesource- The template sourcereload- : Indicate if we must clean the cache- Returns:
- A Template
-
loadString
public static BaseTemplate loadString(java.lang.String source)
Load template from a String, but don't cache it- Parameters:
source- The template source- Returns:
- A Template
-
cleanCompiledCache
public static void cleanCompiledCache()
Cleans the cache for all templates
-
cleanCompiledCache
public static void cleanCompiledCache(java.lang.String key)
Cleans the specified key from the cache- Parameters:
key- The template key
-
load
public static Template load(java.lang.String path)
Load a template- Parameters:
path- The path of the template (ex: Application/index.html)- Returns:
- The executable template
-
getAllTemplate
public static java.util.List<Template> getAllTemplate()
List all found templates- Returns:
- A list of executable templates
-
-