Class Mustache.StringSegment

java.lang.Object
com.samskivert.mustache.Template.Segment
com.samskivert.mustache.Mustache.StringSegment
Enclosing class:
Mustache

protected static class Mustache.StringSegment extends Template.Segment
A simple segment that reproduces a string.
  • Field Details

    • _text

      protected final String _text
    • _leadBlank

      protected final int _leadBlank
    • _trailBlank

      protected final int _trailBlank
    • _first

      protected final boolean _first
  • Constructor Details

    • StringSegment

      public StringSegment(String text, boolean first)
    • StringSegment

      public StringSegment(String text, int leadBlank, int trailBlank, boolean first)
  • Method Details

    • leadsBlank

      public boolean leadsBlank()
    • trailsBlank

      public boolean trailsBlank()
    • trimLeadBlank

      public Mustache.StringSegment trimLeadBlank()
    • trimTrailBlank

      public Mustache.StringSegment trimTrailBlank()
    • indent

      String indent()
      Calculate indent for partial idententation
      Returns:
      indent space or empty string
    • indent

      Mustache.StringSegment indent(String indent, boolean first, boolean last)
      Description copied from class: Template.Segment
      Recursively indent by the parameter indent.
      Specified by:
      indent in class Template.Segment
      Parameters:
      indent - should be space characters that are not \n.
      first - append indent to the first line (regardless if it has a \n or not).
      last - append indent on the last \n that has no text after it.
      Returns:
      a newly created segment or the same segment if nothing changed.
    • isStandalone

      boolean isStandalone()
      Description copied from class: Template.Segment
      Whether or not the segment is standalone. The definition of standalone is defined by the mustache spec. String and variable tags are never standalone. For blocks this is based on the closing tag. Once trim is called, standalone tags are determined so that proper (re)indentation will work without reparsing the template.
      Specified by:
      isStandalone in class Template.Segment
      Returns:
      true if the tag is standalone.
    • execute

      public void execute(Template tmpl, Template.Context ctx, Writer out)
      Specified by:
      execute in class Template.Segment
    • decompile

      public void decompile(Mustache.Delims delims, StringBuilder into)
      Specified by:
      decompile in class Template.Segment
    • visit

      public void visit(Mustache.Visitor visitor)
      Specified by:
      visit in class Template.Segment
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • reindent

      private static String reindent(String input, String indent, boolean first, boolean last)
    • blankPos

      private static int blankPos(String text, boolean leading, boolean first)