com.x5.template
Class TemplateSetSlice

java.lang.Object
  extended by com.x5.template.TemplateSet
      extended by com.x5.template.TemplateSetSlice
All Implemented Interfaces:
ChunkFactory, ContentSource

public class TemplateSetSlice
extends TemplateSet

TemplateSetSlice enables the formation of a TemplateSet from a single file
with multiple subtemplate definitions a la {#optional_part}bla bla bla{#}.

It maps the concept of fetching a template from within a folder of templates
to fetching a subtemplate from within a file of subtemplates.

Copyright: Copyright (c) 2003
Company: X5 Software
Updates: www.dagblastit.com

Version:
2.0
Author:
Tom McClure

Field Summary
 
Fields inherited from class com.x5.template.TemplateSet
BLOCKEND_LONGHAND, BLOCKEND_SHORTHAND, DEFAULT_TAG_END, DEFAULT_TAG_START, INCLUDE_SHORTHAND, PROTOCOL_SHORTHAND
 
Constructor Summary
TemplateSetSlice(TemplateSet parent, java.lang.String templateContext)
           
TemplateSetSlice(TemplateSet parent, java.lang.String templateContext, java.lang.String ext)
           
 
Method Summary
 Snippet getSnippet(java.lang.String templateName)
          Retrieve as String the template specified by name.
 Chunk makeChunk()
          Creates a Chunk with no starter template and sets its tag boundary markers to match the other templates in this set.
 Chunk makeChunk(java.lang.String templateName)
          Creates a Chunk with a starting template.
 
Methods inherited from class com.x5.template.TemplateSet
addProtocol, clearCache, convertTags, convertTags, convertToMyTags, fetch, getDefaultExtension, getFilters, getFromCache, getProtocol, getResourcePath, getSnippet, getSubset, getTemplatePath, makeChunk, provides, removeBlockTagIndents, setDirtyInterval, setEncoding, setJarContext, setJarContext, setLayerName, signalFailureWithNull
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TemplateSetSlice

public TemplateSetSlice(TemplateSet parent,
                        java.lang.String templateContext)

TemplateSetSlice

public TemplateSetSlice(TemplateSet parent,
                        java.lang.String templateContext,
                        java.lang.String ext)
Method Detail

getSnippet

public Snippet getSnippet(java.lang.String templateName)
Description copied from class: TemplateSet
Retrieve as String the template specified by name. If name contains one or more dots it is assumed that the template definition is nested inside another template. Everything up to the first dot is part of the filename (appends the DEFAULT extension to find the file) and everything after refers to a location within the file where the template contents are defined.

For example: String myTemplate = templateSet.get("outer_file.inner_template");

will look for {#inner_template}bla bla bla{#} inside the file "outer_file.html" or "outer_file.xml" ie whatever your TemplateSet extension is.

Specified by:
getSnippet in interface ContentSource
Overrides:
getSnippet in class TemplateSet
Parameters:
templateName - the location of the template definition.
Returns:
the template definition from the file as a String

makeChunk

public Chunk makeChunk()
Description copied from class: TemplateSet
Creates a Chunk with no starter template and sets its tag boundary markers to match the other templates in this set. The Chunk will need to obtain template pieces via its .append() method.

Specified by:
makeChunk in interface ChunkFactory
Overrides:
makeChunk in class TemplateSet
Returns:
blank Chunk.

makeChunk

public Chunk makeChunk(java.lang.String templateName)
Description copied from class: TemplateSet
Creates a Chunk with a starting template. If templateName contains one or more dots it is assumed that the template definition is nested inside another template. Everything up to the first dot is part of the filename (appends the DEFAULT extension to find the file) and everything after refers to a location within the file where the template contents are defined.

Specified by:
makeChunk in interface ChunkFactory
Overrides:
makeChunk in class TemplateSet
Parameters:
templateName - the location of the template definition.
Returns:
a Chunk pre-initialized with a snippet of template.


Copyright © 2015. All Rights Reserved.