Skip to content
This repository has been archived by the owner on Feb 27, 2022. It is now read-only.

Commit

Permalink
Make the cr_counter more readable.
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Jan 3, 2010
1 parent d8cf8de commit 78a05e2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
11 changes: 4 additions & 7 deletions lib/utils/ejs.js
Expand Up @@ -152,9 +152,10 @@ function ejs_parseStr (src, filename) {
// pop the '<' off the html_buffer, since we don't want to print that // pop the '<' off the html_buffer, since we don't want to print that
html_buffer.pop(); html_buffer.pop();
} }
// push the print statement onto the output buffer while (cr_count > 0) {

out.push(CHR_CR);
for ( cr_count ++; --cr_count > 0;) out.push(CHR_CR); cr_count --;
}
if (html_buffer.length) { if (html_buffer.length) {
out.push(';print(', JSON.stringify(html_buffer.join("")), ');'); out.push(';print(', JSON.stringify(html_buffer.join("")), ');');
} }
Expand All @@ -164,7 +165,6 @@ function ejs_parseStr (src, filename) {
html_buffer.push(c); html_buffer.push(c);
} }
} else if ( state === STATE_JS && c !== EOF ) { } else if ( state === STATE_JS && c !== EOF ) {
// figure out if we want code or print.
if (c === CHR_EQ) { if (c === CHR_EQ) {
state = STATE_JS_PRINT_START; state = STATE_JS_PRINT_START;
} else { } else {
Expand All @@ -174,7 +174,6 @@ function ejs_parseStr (src, filename) {
// that's so that we don't bork on <%%> // that's so that we don't bork on <%%>
i --; i --;
} else if (state === STATE_JS_PRINT_START && c !== EOF) { } else if (state === STATE_JS_PRINT_START && c !== EOF) {
// push the print statement onto the buffer.
out.push("print("); out.push("print(");
state = STATE_JS_PRINT; state = STATE_JS_PRINT;
} else if (str_state === STATE_STR1 && c !== EOF) { } else if (str_state === STATE_STR1 && c !== EOF) {
Expand Down Expand Up @@ -226,8 +225,6 @@ function ejs_parseStr (src, filename) {
str_state = STATE_NO_STR; str_state = STATE_NO_STR;
com_state = STATE_NO_COMMENT; com_state = STATE_NO_COMMENT;
} else if (com_state === STATE_LINECOM) { } else if (com_state === STATE_LINECOM) {
// out.push("\n//",STATE_LINECOM," ",c);
// process.stdio.writeError(c);
if ( if (
c === CHR_CR c === CHR_CR
|| c === CHR_PCT && arr[i + 1] === CHR_CLOSE || c === CHR_PCT && arr[i + 1] === CHR_CLOSE
Expand Down
2 changes: 1 addition & 1 deletion www/ejs/test.ejs.html
Expand Up @@ -43,6 +43,6 @@ <h1>hello</h1>
true true




hello goodbye


<h2>let's see if it worked, neh?</h2> <h2>let's see if it worked, neh?</h2>

0 comments on commit 78a05e2

Please sign in to comment.