Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* Copyright (c) 2012-2015 Edgar Espina
*
* This file is part of Handlebars.java.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.jknack.handlebars.internal;
import static org.apache.commons.lang3.StringUtils.join;
import static org.apache.commons.lang3.Validate.notNull;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.Writer;
import java.nio.charset.Charset;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import com.github.jknack.handlebars.Context;
import com.github.jknack.handlebars.Handlebars;
import com.github.jknack.handlebars.HandlebarsError;
import com.github.jknack.handlebars.HandlebarsException;
import com.github.jknack.handlebars.Template;
import com.github.jknack.handlebars.io.TemplateLoader;
import com.github.jknack.handlebars.io.TemplateSource;
/**
* Partials begin with a greater than sign, like {{> box}}.
* Partials are rendered at runtime (as opposed to compile time), so recursive
* partials are possible. Just avoid infinite loops.
* They also inherit the calling context.
*
* @author edgar.espina
* @since 0.1.0
*/
class Partial extends HelperResolver {
/**
* The partial path.
*/
private Template path;
/**
* A partial context. Optional.
*/
private String context;
/** Null-Safe version of {@link #context}. */
private String scontext;
/**
* The start delimiter.
*/
private String startDelimiter;
/**
* The end delimiter.
*/
private String endDelimiter;
/**
* The indent to apply to the partial.
*/
private String indent;
/** Template loader. */
private TemplateLoader loader;
/** A partial block body. */
private Template partial;
/**
* Creates a new {@link Partial}.
*
* @param handlebars The Handlebars object. Required.
* @param path The template path.
* @param context The template context.
* @param hash Template params
*/
public Partial(final Handlebars handlebars, final Template path, final String context,
final Map hash) {
super(handlebars);
this.path = notNull(path, "The path is required.");
this.context = context;
this.scontext = context == null ? "this" : context;
this.hash(hash);
this.loader = handlebars.getLoader();
}
@Override
public void before(final Context context, final Writer writer) throws IOException {
LinkedList