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.template; 18 19 import com.google.clearsilver.jsilver.autoescape.EscapeMode; 20 import com.google.clearsilver.jsilver.resourceloader.ResourceLoader; 21 22 /** 23 * Loads a Template. 24 */ 25 public interface TemplateLoader { 26 27 /** 28 * Load a template from a named resource, with the provided escape mode. If the mode is 29 * ESCAPE_HTML, ESCAPE_URL or ESCAPE_JS, the corresponding escaping will be all variables in the 30 * template. If the mode is ESCAPE_AUTO, enable <a href="http://go/autoescapecs">auto escaping</a> 31 * on templates. For each variable in the template, this will determine what type of escaping 32 * should be applied to the variable, and automatically apply this escaping. 33 * 34 * @param templateName e.g. some/path/to/template.cs 35 * @param resourceLoader the ResourceLoader object to use to load any files needed to satisfy this 36 * request. 37 * @param escapeMode the type of escaping to apply to the entire template. 38 */ load(String templateName, ResourceLoader resourceLoader, EscapeMode escapeMode)39 Template load(String templateName, ResourceLoader resourceLoader, EscapeMode escapeMode); 40 41 /** 42 * Create a temporary template from content, with the provided escape mode. If the mode is 43 * ESCAPE_HTML, ESCAPE_URL or ESCAPE_JS, the corresponding escaping will be all variables in the 44 * template. If the mode is ESCAPE_AUTO, enable <a href="http://go/autoescapecs">auto escaping</a> 45 * on templates. For each variable in the template, this will determine what type of escaping 46 * should be applied to the variable, and automatically apply this escaping. 47 * 48 * @param name A name to identify the temporary template in stack traces. 49 * @param content e.g. "Hello <cs var:name >" 50 * @param escapeMode the type of escaping to apply to the entire template. 51 */ createTemp(String name, String content, EscapeMode escapeMode)52 Template createTemp(String name, String content, EscapeMode escapeMode); 53 } 54