incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r602886 - in /incubator/sling/trunk/scripting/javascript/src: main/java/org/apache/sling/scripting/javascript/EspReader.java test/java/org/apache/sling/scripting/javascript/EspReaderTest.java
Date Mon, 10 Dec 2007 12:37:12 GMT
Author: bdelacretaz
Date: Mon Dec 10 04:37:11 2007
New Revision: 602886

URL: http://svn.apache.org/viewvc?rev=602886&view=rev
Log:
SLING-114 - reverting r602834: causes out-of-sync line numbers in generated javascript code,
as discussed on the sling dev list

Modified:
    incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/EspReader.java
    incubator/sling/trunk/scripting/javascript/src/test/java/org/apache/sling/scripting/javascript/EspReaderTest.java

Modified: incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/EspReader.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/EspReader.java?rev=602886&r1=602885&r2=602886&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/EspReader.java
(original)
+++ incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/EspReader.java
Mon Dec 10 04:37:11 2007
@@ -184,7 +184,7 @@
      * to output data. Automatically inserted by the reader in code,
      * where needed.
      */
-    public static final String DEFAULT_OUT_INIT_STATEMENT = "out=response.writer;\n"; 
+    public static final String DEFAULT_OUT_INIT_STATEMENT = "out=response.writer;"; 
     private String outInitStatement = DEFAULT_OUT_INIT_STATEMENT;
 
     /**
@@ -399,7 +399,7 @@
                 // if a template text line is still incomplete, inject
                 // proper line ending and continue until this has been returned
                 if (!lineStart && state == PARSE_STATE_ESP) {
-                    doVerbatim("\");\n"); // line ending injection
+                    doVerbatim("\");"); // line ending injection
                     lineStart = true; // mark the line having ended
                     continue; // let's start read the injection
                 }
@@ -432,7 +432,7 @@
                                 pushState(PARSE_STATE_ECMA_EXPR);
                                 startWrite(null);
                                 if (!lineStart) {
-                                    doVerbatim("\");\n");
+                                    doVerbatim("\");");
                                 }
                                 continue;
 
@@ -454,7 +454,7 @@
                             input.unread(c3);
                             pushState(PARSE_STATE_ECMA);
                             if (!lineStart) {
-                                doVerbatim("\");\n");
+                                doVerbatim("\");");
                             }
                             continue;
 
@@ -527,7 +527,7 @@
 
                             // An expression is wrapped in out.write()
                             if (popState() == PARSE_STATE_ECMA_EXPR) {
-                                doVerbatim(");\n");
+                                doVerbatim(");");
                             }
 
                             // next ESP needs out.write(
@@ -595,7 +595,7 @@
                         // terminate an open template line
                         if (!lineStart) {
                             input.unread(c); // push back the character
-                            doVerbatim("\");\n"); // insert ");
+                            doVerbatim("\");"); // insert ");
                             lineStart = true; // mark the line start
                             continue; // Force read of the "
                         }

Modified: incubator/sling/trunk/scripting/javascript/src/test/java/org/apache/sling/scripting/javascript/EspReaderTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/javascript/src/test/java/org/apache/sling/scripting/javascript/EspReaderTest.java?rev=602886&r1=602885&r2=602886&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/javascript/src/test/java/org/apache/sling/scripting/javascript/EspReaderTest.java
(original)
+++ incubator/sling/trunk/scripting/javascript/src/test/java/org/apache/sling/scripting/javascript/EspReaderTest.java
Mon Dec 10 04:37:11 2007
@@ -85,14 +85,14 @@
 
     /** Test standard template text */
     public void testTemplate() throws IOException {
-        assertEquals("out=response.writer;\nout.write(\"test\");\n", parse("test"));
-        assertEquals("out=response.writer;\nout.write(\"test\\n\");\nout.write(\"test2\");\n",
parse("test\ntest2"));
+        assertEquals("out=response.writer;out.write(\"test\");", parse("test"));
+        assertEquals("out=response.writer;out.write(\"test\\n\");\nout.write(\"test2\");",
parse("test\ntest2"));
     }
     
     /** Test with a custom "out" initialization */
     public void testOutInit() throws IOException {
         final String input = "test";
-        final String expected = "out=getOut();out.write(\"test\");\n";
+        final String expected = "out=getOut();out.write(\"test\");";
             
         StringBuffer buf = new StringBuffer();
 
@@ -114,8 +114,8 @@
 
     /** Test JavaScript expressions */
     public void testExpr() throws IOException {
-        assertEquals("out=response.writer;\nout.write( x + 1 );\n", parse("<%= x + 1 %>"));
-        assertEquals("out=response.writer;\nout.write(\"<!-- \");\nout.write( x + 1 );\nout.write(\"
-->\");\n", parse("<!-- <%= x + 1 %> -->"));
+        assertEquals("out=response.writer;out.write( x + 1 );", parse("<%= x + 1 %>"));
+        assertEquals("out=response.writer;out.write(\"<!-- \");out.write( x + 1 );out.write(\"
-->\");", parse("<!-- <%= x + 1 %> -->"));
     }
 
     /** Test JavaScript comment */
@@ -143,11 +143,8 @@
         ;
         
         final String expected = 
-            "out=response.writer;\n"
-            + "out.write(\"<html>\\n\");\n"
-            + "out.write(\"<head><title>\");\n"
-            + "out.write( someExpr );\n"
-            + "out.write(\"</title></head>\\n\");\n"
+            "out=response.writer;out.write(\"<html>\\n\");\n"
+            + "out.write(\"<head><title>\");out.write( someExpr );out.write(\"</title></head>\\n\");\n"
             + "out.write(\"<!-- some HTML comment -->\\n\");\n"
             + "out.write(\"<-- some ESP comment -->\\n\");\n"
             + "out.write(\"// some javascript comment\\n\");\n"
@@ -158,10 +155,9 @@
             + "out.write(\"\\n\");\n"
             + "out.write(\"<verbatim stuff=\\\"quoted\\\">xyz</verbatim>\\n\");\n"
             + "out.write(\"<moreverbatim stuff='single'>xx</moreverbatim>\\n\");\n"
-            + "out.write(\"<!-- HTML comment with \");\n"
-            + " expr.here; out.write(\" and EOL\\n\");\n"
+            + "out.write(\"<!-- HTML comment with \"); expr.here; out.write(\" and EOL\\n\");\n"
             + "out.write(\"-->\\n\");\n"
-            + "out.write(\"</html>\");\n"
+            + "out.write(\"</html>\");"
         ;
         
         final String actual = parse(input);



Mime
View raw message