• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.google.clearsilver.jsilver.interpreter;
18 
19 import com.google.clearsilver.jsilver.autoescape.EscapeMode;
20 import com.google.clearsilver.jsilver.resourceloader.ResourceLoader;
21 import com.google.clearsilver.jsilver.syntax.TemplateSyntaxTree;
22 
23 /**
24  * Responsible for creating/retrieving an AST tree for a template with a given name.
25  * <p>
26  * This interface always expects to take a ResourceLoader object from the caller. This helps
27  * guarantee that per-Template resourceLoaders are respected.
28  */
29 public interface TemplateFactory {
30 
31   /**
32    * Load a template from the source.
33    *
34    * @param templateName e.g. some/path/to/template.cs
35    * @param resourceLoader use this ResourceLoader to locate the named template file and any
36    *        included files.
37    * @param escapeMode the type of escaping to apply to the entire template.
38    */
find(String templateName, ResourceLoader resourceLoader, EscapeMode escapeMode)39   TemplateSyntaxTree find(String templateName, ResourceLoader resourceLoader, EscapeMode escapeMode);
40 
41   /**
42    * Create a temporary template from content.
43    *
44    * @param content e.g. "Hello &lt;cs var:name &gt;"
45    * @param escapeMode
46    * @param escapeMode the type of escaping to apply to the entire template.
47    */
createTemp(String content, EscapeMode escapeMode)48   TemplateSyntaxTree createTemp(String content, EscapeMode escapeMode);
49 
50 }
51