Package templating

Class Templating

java.lang.Object
templating.Templating

public class Templating
extends java.lang.Object
Implements templating methods similar to typo3 Simple tag markers must be upper-case. The must appear in templates embraced by three hash signs, e.g. ###MARKER###
Author:
RalphSchuster
  • Constructor Summary

    Constructors 
    Constructor Description
    Templating()  
  • Method Summary

    Modifier and Type Method Description
    static java.lang.String getSubTemplate​(java.lang.String template, java.lang.String name)
    Returns a sub template.
    static java.lang.String getTemplate​(java.io.File f)
    Returns a template from a file.
    static java.lang.String getTemplate​(java.lang.String filename)
    Returns a template from a file.
    static java.lang.String replace​(java.lang.String template, java.lang.String marker, java.lang.Object value)
    Replaces a simple marker by its value.
    static java.lang.String replace​(java.lang.String template, java.util.Map<java.lang.String,​java.lang.Object> markers)
    Replaces multiple simple tag markers.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • replace

      public static java.lang.String replace​(java.lang.String template, java.lang.String marker, java.lang.Object value)
      Replaces a simple marker by its value. Simple tag markers must be upper-case. The must appear in templates embraced by three hash signs, e.g. ###MARKER###
      Parameters:
      template - - text template
      marker - - marker name, e.g. MARKER
      value - - value to be replaced
      Returns:
      the template string with replacements of all markers
    • replace

      public static java.lang.String replace​(java.lang.String template, java.util.Map<java.lang.String,​java.lang.Object> markers)
      Replaces multiple simple tag markers. Simple tag markers must be upper-case. The must appear in templates embraced by three hash signs, e.g. ###MARKER###
      Parameters:
      template - - text template
      markers - - markers map
      Returns:
      - replaced template text
    • getSubTemplate

      public static java.lang.String getSubTemplate​(java.lang.String template, java.lang.String name)
      Returns a sub template. Sub templates are enclosed by XML comment tags as known from TYPO3: <!-- ###MARKER### begin --> my sub template text <!-- ###MARKER### end --> Sub templates of same name are not allowed
      Parameters:
      template - - parent template
      name - - name of sub template, e.g. MARKER
      Returns:
      sub template, or null if not found
    • getTemplate

      public static java.lang.String getTemplate​(java.lang.String filename) throws java.io.IOException
      Returns a template from a file.
      Parameters:
      filename - - filename
      Returns:
      template's content
      Throws:
      java.io.IOException - when an error occurred
    • getTemplate

      public static java.lang.String getTemplate​(java.io.File f) throws java.io.IOException
      Returns a template from a file.
      Parameters:
      f - - file object to load from
      Returns:
      template's content
      Throws:
      java.io.IOException - when an error occurred