Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright 2013, Emanuel Rabina (http://www.ultraq.net.nz/)
  * 
  * 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 nz.net.ultraq.thymeleaf.include;
import static nz.net.ultraq.thymeleaf.FragmentProcessor.PROCESSOR_NAME_FRAGMENT;
import static nz.net.ultraq.thymeleaf.LayoutDialect.DIALECT_PREFIX_LAYOUT;
Similar to Thymeleaf's th:substituteby, but allows the passing of entire element fragments to the included template. Useful if you have some HTML that you want to reuse, but whose contents are too complex to determine or construct with context variables alone.

Deprecated:
Use the ReplaceProcessor instead.
Author(s):
Emanuel Rabina
	public static final String PROCESSOR_NAME_SUBSTITUTEBY = "substituteby";

Constructor, set this processor to work on the 'substituteby' attribute.
	}

Locates the specified page/fragment and brings it into the current template.

Parameters:
arguments
element
attributeName
Returns:
Result of the processing.
	protected ProcessorResult processAttribute(Arguments argumentsElement elementString attributeName) {
		// Locate the page and fragment to include
		StandardFragment fragment = StandardFragmentProcessor.computeStandardFragmentSpec(
				arguments.getConfiguration(), argumentselement.getAttributeValue(attributeName),
		List<Nodeincludefragments = fragment.extractFragment(arguments.getConfiguration(),
				argumentsarguments.getTemplateRepository());
		element.removeAttribute(attributeName);
		// Gather all fragment parts within the substituteby element
		Map<String,Objectpagefragments = findFragments(element.getElementChildren());
		// Replace the children of this element with those of the substituteby
		// page fragments, scoping any fragment parts to the immediate children
		element.clearChildren();
		if (includefragments != null) {
			for (Node includefragmentincludefragments) {
				includefragment.setAllNodeLocalVariables(pagefragments);
				element.addChild(includefragment);
			}
		}
		element.getParent().extractChild(element);
	}
New to GrepCode? Check out our FAQ X