4343 */
4444public class IndentedLambda implements Mustache .Lambda {
4545 private final int prefixSpaceCount ;
46+ private final String prefix ;
4647 private int spaceCode ;
4748
4849 /**
4950 * Constructs a new instance of {@link IndentedLambda}, with an indent count of 4 spaces
5051 */
5152 public IndentedLambda () {
52- this (4 , " " );
53+ this (4 , " " , null );
5354 }
5455
5556 /**
@@ -59,15 +60,38 @@ public IndentedLambda() {
5960 * @param indentionCharacter String representation of the character used in the indent (e.g. " ", "\t", ".").
6061 */
6162 public IndentedLambda (int prefixSpaceCount , String indentionCharacter ) {
62- this (prefixSpaceCount , Character .codePointAt (indentionCharacter , 0 ));
63+ this (prefixSpaceCount , Character .codePointAt (indentionCharacter , 0 ), null );
64+ }
65+
66+ /**
67+ * Constructs a new instance of {@link IndentedLambda}, with customized indent count and intention character
68+ *
69+ * @param prefixSpaceCount The number of indented characters to apply as a prefix to a fragment.
70+ * @param indentionCharacter String representation of the character used in the indent (e.g. " ", "\t", ".").
71+ * @param prefix An optional prefix to prepend before the line (useful for multi-line comments).
72+ */
73+ public IndentedLambda (int prefixSpaceCount , String indentionCharacter , String prefix ) {
74+ this (prefixSpaceCount , Character .codePointAt (indentionCharacter , 0 ), prefix );
6375 }
6476
6577 /**
6678 * Constructs a new instance of {@link IndentedLambda}
6779 *
6880 * @param prefixSpaceCount The number of indented characters to apply as a prefix to a fragment.
81+ * @param indentionCodePoint Code point of the single character used for indentation.
6982 */
7083 private IndentedLambda (int prefixSpaceCount , int indentionCodePoint ) {
84+ this (prefixSpaceCount , indentionCodePoint , null );
85+ }
86+
87+ /**
88+ * Constructs a new instance of {@link IndentedLambda}
89+ *
90+ * @param prefixSpaceCount The number of indented characters to apply as a prefix to a fragment.
91+ * @param indentionCodePoint Code point of the single character used for indentation.
92+ * @param prefix An optional prefix to prepend before the line (useful for multi-line comments).
93+ */
94+ private IndentedLambda (int prefixSpaceCount , int indentionCodePoint , String prefix ) {
7195 if (prefixSpaceCount <= 0 ) {
7296 throw new IllegalArgumentException ("prefixSpaceCount must be greater than 0" );
7397 }
@@ -78,6 +102,7 @@ private IndentedLambda(int prefixSpaceCount, int indentionCodePoint) {
78102
79103 this .prefixSpaceCount = prefixSpaceCount ;
80104 this .spaceCode = indentionCodePoint ;
105+ this .prefix = prefix ;
81106 }
82107
83108 @ Override
@@ -96,6 +121,7 @@ public void execute(Template.Fragment fragment, Writer writer) throws IOExceptio
96121 // So, we want to skip the first line.
97122 if (i > 0 ) {
98123 sb .append (prefixedIndention );
124+ if (prefix != null ) sb .append (prefix );
99125 }
100126
101127 sb .append (line );
0 commit comments