Permalink
Browse files

preserve line feeds, update license, remove shim

  • Loading branch information...
1 parent 0030723 commit 30a27d7e0b7f0bad4b98b3418defc9f4f41e730c @chjj committed Jan 4, 2012
Showing with 32 additions and 43 deletions.
  1. +19 −19 LICENSE
  2. +2 −1 lib/lexer.js
  3. +8 −19 lib/liquor.js
  4. +1 −2 lib/parser.js
  5. +2 −2 package.json
View
@@ -1,19 +1,19 @@
-Copyright (c) 2011, Christopher Jeffrey (http://epsilon-not.net/)
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
+Copyright (c) 2011-2012, Christopher Jeffrey (github.com/chjj)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
View
@@ -3,7 +3,7 @@
* Copyright (c) 2011, Christopher Jeffrey. (MIT Licensed)
*/
-var lexer = function(str) {
+var lexer = function(str, options) {
str = str.replace(/\r\n|\r/g, '\n')
.replace(/"/g, '\\"');
@@ -58,6 +58,7 @@ var lexer = function(str) {
line: line
});
} else {
+ if (options.pretty) buff += '\\n';
tokens.push({
type: 'text',
text: buff,
View
@@ -4,19 +4,21 @@
* Copyright (c) 2011, Christopher Jeffrey. (MIT Licensed)
*/
-var lex = require('./lexer')
- , parse = require('./parser');
+var lexer = require('./lexer')
+ , parser = require('./parser');
/**
* Compile
*/
-var liquor = function(str, opt) {
- str = parse(lex(str));
+var liquor = function(text, options) {
+ options = options || {};
- if (opt === 'debug') return str;
+ text = parser(lexer(text, options), options);
- var func = new Function('$, each', str);
+ if (options === 'debug') return text;
+
+ var func = new Function('$, each', text);
return function(locals) {
return func(locals || {}, each);
};
@@ -61,16 +63,3 @@ if (typeof module !== 'undefined' && module.exports) {
} else {
this.liquor = liquor;
}
-
-/**
- * Client-Side Shim
- */
-
-if (!Object.keys) {
- var hop = Object.prototype.hasOwnProperty;
- Object.keys = function(o) {
- var k, c = [];
- if (o) for (k in o) if (hop.call(o, k)) c.push(k);
- return c;
- };
-}
View
@@ -54,7 +54,7 @@ var parser = (function() {
}
};
- return function(src) {
+ return function(src, options) {
var out = [];
tokens = src.reverse();
@@ -75,7 +75,6 @@ var parser = (function() {
out = 'with ($) { var __out = []; __out.push("'
+ out
+ '"); return __out.join(""); }';
- out = out.replace(/\n/g, '\\n');
token = null;
tokens = null;
View
@@ -2,8 +2,8 @@
"name": "liquor",
"description": "templates without the code",
"author": "Christopher Jeffrey",
- "version": "0.0.1",
+ "version": "0.0.2",
"main": "./lib/liquor.js",
"repository": "git://github.com/chjj/liquor.git",
"keywords": [ "template" ]
-}
+}

0 comments on commit 30a27d7

Please sign in to comment.