Comparing version 1.2.2 to 1.3.0
@@ -154,2 +154,21 @@ "use strict"; | ||
} | ||
}, | ||
code: function(node, context) { | ||
return { | ||
content: new OutputBuffer(), | ||
scope: context.scope, | ||
parent: context, | ||
done: function() { | ||
this.parent.content.addCode(node.code.trimLeft() + "\n"); | ||
if(this.content.parts.length !== 0) { | ||
this.parent.content.addCode("{"); | ||
this.parent.content.addBuffer(this.content); | ||
this.parent.content.addCode("}\n"); | ||
} else { | ||
this.parent.content.addCode(";"); | ||
this.parent.content.addBuffer(this.content); | ||
} | ||
} | ||
}; | ||
} | ||
@@ -156,0 +175,0 @@ }; |
{ | ||
"name": "razorleaf", | ||
"version": "1.2.2", | ||
"version": "1.3.0", | ||
"main": "razorleaf.js", | ||
@@ -5,0 +5,0 @@ "files": [ |
@@ -121,2 +121,15 @@ "use strict"; | ||
if(c === "%") { | ||
this.context = { | ||
type: "code", | ||
code: "", | ||
parent: this.context, | ||
indent: this.indent, | ||
children: [], | ||
unexpected: this.error("Code here is not valid") | ||
}; | ||
this.context.parent.children.push(this.context); | ||
return states.code; | ||
} | ||
if(c === "\"") { | ||
@@ -162,2 +175,12 @@ this.context = { | ||
}, | ||
code: function(c) { | ||
if(c === "\n") { | ||
this.indent = 0; | ||
return states.indent; | ||
} | ||
this.context.code += c; | ||
return states.code; | ||
}, | ||
comment: function(c) { | ||
@@ -164,0 +187,0 @@ if(c === "\n") { |
@@ -122,2 +122,24 @@ [![Build Status](https://travis-ci.org/campersander/razorleaf.png)](https://travis-ci.org/campersander/razorleaf) | ||
### Code | ||
Code blocks begin with `%` and continue to the end of the line. | ||
Code blocks may contain content (strings, elements, other code blocks, | ||
and special blocks, but not attributes); if they do, they are treated as blocks | ||
and wrapped in curly braces. | ||
For example, this template: | ||
``` | ||
% if(i < 5) | ||
!"#{i}" | ||
``` | ||
might compile to this JavaScript: | ||
```javascript | ||
if(i < 5) { | ||
__output += i; | ||
} | ||
``` | ||
### Special blocks | ||
@@ -124,0 +146,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29924
952
181