Exemplo n.º 1
0
  public ParsedResult parseCode(String uri, String gsp) throws IOException {
    // Simulate what the parser does so we get it in the encoding expected
    Object enc = GrailsWebUtil.currentConfiguration().get("grails.views.gsp.encoding");
    if ((enc == null) || (enc.toString().trim().length() == 0)) {
      enc = System.getProperty("file.encoding", "us-ascii");
    }

    InputStream gspIn = new ByteArrayInputStream(gsp.getBytes(enc.toString()));
    GroovyPageParser parse = new GroovyPageParser(uri, uri, uri, gspIn, enc.toString(), "HTML");

    InputStream in = parse.parse();
    ParsedResult result = new ParsedResult();
    result.parser = parse;
    result.generatedGsp = IOGroovyMethods.getText(in, enc.toString());
    result.htmlParts = parse.getHtmlPartsArray();
    return result;
  }