toSource method

String toSource()

Convert this token to its source representation.

Implementation

String toSource() {
	switch (type) {
		// comment
		case TokenType.comment:
			// return text wrapped in comment block with block ends escaped
			return quoteComment(text, true);
		// declarations
		case TokenType.declaration:
			// return declarative tag
			return "<!$tagContent>";
		// tag opener
		case TokenType.tagOpen:
			// return tag open
			return "<$tagContent${selfClosing ? "/>" : ">"}";
		// tag closer
		case TokenType.tagClose:
			// return tag close
			return "</$name>";
		// text
		case TokenType.text:
			// return text with special characters escaped
			return quoteRaw(text);
		// cdata
		case TokenType.cdata:
			// return text wrapped in cdata block with cend tags escaped
			return quoteCdata(text, true);
	}
}