All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.duelengine.duel.ast.MarkupExpressionNode Maven / Gradle / Ivy

package org.duelengine.duel.ast;

public class MarkupExpressionNode extends CodeBlockNode {

	public static final String BEGIN = "<%#";
	public static final String END = "%>";
	private static final String INTRO1 = "function(";
	private static final String INTRO2 = "){return duel.raw(";
	private static final String INTRO2_PRETTY = ") { return duel.raw(";
	private static final String OUTRO = ");}";
	private static final String OUTRO_PRETTY = "); }";

	public MarkupExpressionNode(String expression, int index, int line, int column) {
		super(BEGIN, END, expression, index, line, column);
	}

	public MarkupExpressionNode(String expression) {
		super(BEGIN, END, expression);
	}

	@Override
	public String getClientCode(boolean prettyPrint) {
		StringBuilder buffer = new StringBuilder(INTRO1);
		buffer.append(formatParamList());
		buffer.append(prettyPrint ? INTRO2_PRETTY : INTRO2);
		String value = getValue();
		if (value != null) {
			buffer.append(prettyPrint ? value : value.trim());
		}
		return buffer.append(prettyPrint ? OUTRO_PRETTY : OUTRO).toString();
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy