use of org.thymeleaf.util.FastStringWriter in project thymeleaf by thymeleaf.
the class TemplateModel method toString.
@Override
public final String toString() {
try {
final Writer writer = new FastStringWriter();
write(writer);
return writer.toString();
} catch (final IOException e) {
throw new TemplateProcessingException("Error while creating String representation of model");
}
}
use of org.thymeleaf.util.FastStringWriter in project thymeleaf by thymeleaf.
the class AbstractStandardInliner method inlineSwitchTemplateMode.
private CharSequence inlineSwitchTemplateMode(final ITemplateContext context, final IComment comment) {
final TemplateManager templateManager = context.getConfiguration().getTemplateManager();
/*
* Notice we are ONLY processing the contents of the Comment, because we know the target inlining
* mode will not understand the Comment (it will be textual) and we don't want it to mess around with
* the Comment's prefix and suffix.
*
* Note this will only be executed in markup modes (textual modes never fire "handleComment" events),
* so we are safe assuming the sizes of Comment prefixes and suffixes in HTML/XML.
*/
final TemplateModel templateModel = templateManager.parseString(context.getTemplateData(), comment.getContent(), // +4 because of the prefix
comment.getLine(), // +4 because of the prefix
comment.getCol() + 4, this.templateMode, true);
final Writer stringWriter = new FastStringWriter(50);
templateManager.process(templateModel, context, stringWriter);
return stringWriter.toString();
}
use of org.thymeleaf.util.FastStringWriter in project thymeleaf by thymeleaf.
the class AbstractStandardInliner method inlineSwitchTemplateMode.
private CharSequence inlineSwitchTemplateMode(final ITemplateContext context, final IText text) {
final TemplateManager templateManager = context.getConfiguration().getTemplateManager();
final TemplateModel templateModel = templateManager.parseString(context.getTemplateData(), text.getText(), text.getLine(), text.getCol(), this.templateMode, true);
if (!this.writeTextsToOutput) {
final Writer stringWriter = new FastStringWriter(50);
templateManager.process(templateModel, context, stringWriter);
return stringWriter.toString();
}
// If we can directly write to output (and text is an IText), we will use a LazyProcessingCharSequence
return new LazyProcessingCharSequence(context, templateModel);
}
use of org.thymeleaf.util.FastStringWriter in project thymeleaf by thymeleaf.
the class StandardJavaScriptInliner method produceEscapedOutput.
@Override
protected String produceEscapedOutput(final Object input) {
final Writer jsWriter = new FastStringWriter(input instanceof String ? ((String) input).length() * 2 : 20);
this.serializer.serializeValue(input, jsWriter);
return jsWriter.toString();
}
use of org.thymeleaf.util.FastStringWriter in project thymeleaf by thymeleaf.
the class TemplateEngine method process.
public final String process(final TemplateSpec templateSpec, final IContext context) {
final Writer stringWriter = new FastStringWriter(100);
process(templateSpec, context, stringWriter);
return stringWriter.toString();
}
Aggregations