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 17package com.google.clearsilver.jsilver.interpreter; 18 19import com.google.clearsilver.jsilver.autoescape.EscapeMode; 20import com.google.clearsilver.jsilver.resourceloader.ResourceLoader; 21import 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 */ 29public 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 */ 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 <cs var:name >" 45 * @param escapeMode 46 * @param escapeMode the type of escaping to apply to the entire template. 47 */ 48 TemplateSyntaxTree createTemp(String content, EscapeMode escapeMode); 49 50} 51