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

sirius.web.templates.JavaScriptContentHandler Maven / Gradle / Ivy

There is a newer version: 22.2.3
Show newest version
/*
 * Made with all the love in the world
 * by scireum in Remshalden, Germany
 *
 * Copyright by scireum GmbH
 * http://www.scireum.de - [email protected]
 */

package sirius.web.templates;

import sirius.kernel.di.std.Register;

import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StringWriter;

/**
 * Executes the given JavaScript script (most probably without generating any output).
 * 

* This handler expects JavaScript as template language. The name of this handler is js the expected file * extension is * .js */ @Register(name = JavaScriptContentHandler.JS, classes = ContentHandler.class) public class JavaScriptContentHandler extends JavaScriptBasedContentHandler { /** * Contains the name (type) of this handler */ public static final String JS = "js"; @Override public boolean generate(Generator generator, OutputStream out) throws Exception { if (!JS.equals(generator.getHandlerType()) && !generator.isTemplateFileExtension("js")) { return false; } PrintWriter writer = new PrintWriter(out == null ? new StringWriter() : new OutputStreamWriter(out, generator.getEncoding())); generator.put("out", writer); execute(generator); writer.flush(); return true; } @Override public int getPriority() { return DEFAULT_PRIORITY; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy