156ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson/* 256ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson * Copyright (C) 2010 Google Inc. 356ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson * 456ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson * Licensed under the Apache License, Version 2.0 (the "License"); 556ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson * you may not use this file except in compliance with the License. 656ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson * You may obtain a copy of the License at 756ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson * 856ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson * http://www.apache.org/licenses/LICENSE-2.0 956ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson * 1056ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson * Unless required by applicable law or agreed to in writing, software 1156ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson * distributed under the License is distributed on an "AS IS" BASIS, 1256ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1356ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson * See the License for the specific language governing permissions and 1456ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson * limitations under the License. 1556ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson */ 1656ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson 1756ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodsonpackage com.google.clearsilver.jsilver.template; 1856ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson 1956ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodsonimport com.google.clearsilver.jsilver.autoescape.EscapeMode; 2056ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodsonimport com.google.clearsilver.jsilver.resourceloader.ResourceLoader; 2156ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson 2256ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson/** 2356ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson * Loads a Template. 2456ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson */ 2556ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodsonpublic interface TemplateLoader { 2656ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson 2756ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson /** 2856ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson * Load a template from a named resource, with the provided escape mode. If the mode is 2956ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson * ESCAPE_HTML, ESCAPE_URL or ESCAPE_JS, the corresponding escaping will be all variables in the 3056ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson * template. If the mode is ESCAPE_AUTO, enable <a href="http://go/autoescapecs">auto escaping</a> 3156ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson * on templates. For each variable in the template, this will determine what type of escaping 3256ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson * should be applied to the variable, and automatically apply this escaping. 3356ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson * 3456ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson * @param templateName e.g. some/path/to/template.cs 3556ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson * @param resourceLoader the ResourceLoader object to use to load any files needed to satisfy this 3656ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson * request. 3756ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson * @param escapeMode the type of escaping to apply to the entire template. 3856ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson */ 3956ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson Template load(String templateName, ResourceLoader resourceLoader, EscapeMode escapeMode); 4056ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson 4156ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson /** 4256ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson * Create a temporary template from content, with the provided escape mode. If the mode is 4356ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson * ESCAPE_HTML, ESCAPE_URL or ESCAPE_JS, the corresponding escaping will be all variables in the 4456ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson * template. If the mode is ESCAPE_AUTO, enable <a href="http://go/autoescapecs">auto escaping</a> 4556ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson * on templates. For each variable in the template, this will determine what type of escaping 4656ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson * should be applied to the variable, and automatically apply this escaping. 4756ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson * 4856ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson * @param name A name to identify the temporary template in stack traces. 4956ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson * @param content e.g. "Hello <cs var:name >" 5056ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson * @param escapeMode the type of escaping to apply to the entire template. 5156ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson */ 5256ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson Template createTemp(String name, String content, EscapeMode escapeMode); 5356ed4167b942ec265f9cee70ac4d71d10b3835ceBen Dodson} 54