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

play.template2.GTTemplateLocationReal Maven / Gradle / Ivy

Go to download

RePlay is a fork of the Play1 framework, made and maintained by Codeborne.

The newest version!
package play.template2;

import java.net.URL;
import java.util.regex.Pattern;

import static java.util.regex.Pattern.CASE_INSENSITIVE;
import static java.util.regex.Pattern.DOTALL;

public class GTTemplateLocationReal extends GTTemplateLocation {

    private static final Pattern scriptBlockRegex = Pattern.compile("(.*?)", DOTALL | CASE_INSENSITIVE);
    public final URL realFileURL;

    public GTTemplateLocationReal(String relativePath, URL realFileURL) {
        super(relativePath);
        this.realFileURL = realFileURL;
    }

    @Override
    public String readSource() {
        String originalHtml = IO.readContentAsString(realFileURL);
        return addInlineScriptTag(originalHtml);
    }

    String addInlineScriptTag(String originalHtml) {
        return scriptBlockRegex.matcher(originalHtml).replaceAll("#{secureInlineJavaScript}$2#{/secureInlineJavaScript}");
    }

    @Override
    public String toString() {
        return "GTTemplateLocationReal{" +
                "realFile=" + realFileURL +
                "} " + super.toString();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy