Comparing version 0.9.1 to 0.9.2
{ | ||
"name": "razorleaf", | ||
"version": "0.9.1", | ||
"version": "0.9.2", | ||
"main": "razorleaf.js", | ||
@@ -5,0 +5,0 @@ "files": ["razorleaf.js"], |
@@ -23,7 +23,22 @@ "use strict"; | ||
function InterpolatedString(parts) { | ||
function InterpolatedString(parts, unescaped) { | ||
this.parts = parts; | ||
this.unescaped = unescaped; | ||
} | ||
InterpolatedString.prototype.toUnescapedContent = function() { | ||
return this.parts.map(function(part) { | ||
if(typeof part === "string") { | ||
return part; | ||
} | ||
return "' + (" + part.expression + "\n) + '"; | ||
}).join(""); | ||
}; | ||
InterpolatedString.prototype.toAttributeValue = function() { | ||
if(this.unescaped) { | ||
return this.toUnescapedContent(); | ||
} | ||
return this.parts.map(function(part) { | ||
@@ -39,2 +54,6 @@ if(typeof part === "string") { | ||
InterpolatedString.prototype.toContent = function() { | ||
if(this.unescaped) { | ||
return this.toUnescapedContent(); | ||
} | ||
return this.parts.map(function(part) { | ||
@@ -172,2 +191,3 @@ if(typeof part === "string") { | ||
return this.reading(function() { | ||
var unescaped = !!this.readExact("!"); | ||
var quote = this.read(); | ||
@@ -220,3 +240,3 @@ | ||
type: "string", | ||
content: new InterpolatedString(parts) | ||
content: new InterpolatedString(parts, unescaped) | ||
}; | ||
@@ -223,0 +243,0 @@ }); |
@@ -32,2 +32,4 @@ Razor Leaf is a template engine for HTML. It is indentation-based and vaguely | ||
' of Razor Leaf’s features.' | ||
!'Literal <abbr title="HyperText Markup Language">HTML</abbr> content can be written using a string with a leading exclamation mark.' | ||
``` | ||
@@ -74,3 +76,4 @@ | ||
be escaped, but a closing brace (`}`) does. Strings’ contents are escaped as | ||
appropriate. | ||
appropriate. Unescaped strings are marked up with a `!` before the opening | ||
delimiter. | ||
@@ -92,4 +95,3 @@ ### Special blocks | ||
- Replaceable blocks and template extension/inclusion | ||
- Literal (unescaped) strings | ||
[Jade]: http://jade-lang.com/ |
15182
445
95