1 /************************************************************************** 2 * 3 * Copyright (c) 2016-2020 Yawg project contributors. 4 * 5 **************************************************************************/ 6 7 package com.varmateo.yawg.spi; 8 9 import java.util.Optional; 10 11 import com.varmateo.yawg.api.YawgException; 12 13 14 /** 15 * Provider of layout templates for baking. 16 */ 17 public interface TemplateService { 18 19 20 /** 21 * Fetches the template with the given name. 22 * 23 * <p>The meaning and structure of the template name depend on the 24 * concrete template engine being used.</p> 25 * 26 * <p>Do not assume that the same object will be returned for two 27 * calls with the same name. You can only assume the template 28 * objects returned for the same name are functionaly 29 * equivalent.</p> 30 * 31 * @param name The name of the template to return. 32 * 33 * @return The template associated with the given name. If this 34 * service does not support the template format then an empty 35 * <code>Optional</code> will be returned. 36 * 37 * @throws YawgException If for whatever reason it was not 38 * possible to create the page template. For instance, if the 39 * template with the given name does not exist. 40 */ 41 Optional<Template> prepareTemplate(String name); 42 }