Skip to content

Commit

Permalink
Merge 790c1c4 into 1ad26c1
Browse files Browse the repository at this point in the history
  • Loading branch information
aMarCruz committed Dec 7, 2015
2 parents 1ad26c1 + 790c1c4 commit bc56c6a
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 5 deletions.
13 changes: 12 additions & 1 deletion dist/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,11 @@ var brackets = require('riot-tmpl').brackets
if (expr[0] === '^')
expr = expr.slice(1)
else if (jsfn) {
var israw = expr[0] === '='
if (israw) expr = expr.slice(1)
expr = jsfn(expr, opts)
if (/;\s*$/.test(expr)) expr = expr.slice(0, expr.search(/;\s*$/))
if (israw) expr = '=' + expr
}
list[i] = '\u0001' + (pcex.push(expr.replace(/[\r\n]+/g, ' ').trim()) - 1) + _bp[1]
}
Expand All @@ -267,7 +270,15 @@ var brackets = require('riot-tmpl').brackets
if (pcex.length) {
html = html
.replace(/\u0001(\d+)/g, function (_, d) {
return _bp[0] + pcex[d]
var expr = pcex[d]
if (expr[0] === '=')
expr = expr.replace(brackets.R_STRINGS, function (qs) {
return qs

.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
})
return _bp[0] + expr
})
}
return html
Expand Down
13 changes: 12 additions & 1 deletion dist/es6.compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,11 @@ var parsers = (function () {
if (expr[0] === '^')
expr = expr.slice(1)
else if (jsfn) {
var israw = expr[0] === '='
if (israw) expr = expr.slice(1)
expr = jsfn(expr, opts)
if (/;\s*$/.test(expr)) expr = expr.slice(0, expr.search(/;\s*$/))
if (israw) expr = '=' + expr
}
list[i] = '\u0001' + (pcex.push(expr.replace(/[\r\n]+/g, ' ').trim()) - 1) + _bp[1]
}
Expand All @@ -225,7 +228,15 @@ var parsers = (function () {
if (pcex.length) {
html = html
.replace(/\u0001(\d+)/g, function (_, d) {
return _bp[0] + pcex[d]
var expr = pcex[d]
if (expr[0] === '=')
expr = expr.replace(brackets.R_STRINGS, function (qs) {
return qs

.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
})
return _bp[0] + expr
})
}
return html
Expand Down
13 changes: 12 additions & 1 deletion dist/riot.compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,11 @@ var compile = (function () {
if (expr[0] === '^')
expr = expr.slice(1)
else if (jsfn) {
var israw = expr[0] === '='
if (israw) expr = expr.slice(1)
expr = jsfn(expr, opts)
if (/;\s*$/.test(expr)) expr = expr.slice(0, expr.search(/;\s*$/))
if (israw) expr = '=' + expr
}
list[i] = '\u0001' + (pcex.push(expr.replace(/[\r\n]+/g, ' ').trim()) - 1) + _bp[1]
}
Expand All @@ -223,7 +226,15 @@ var compile = (function () {
if (pcex.length) {
html = html
.replace(/\u0001(\d+)/g, function (_, d) {
return _bp[0] + pcex[d]
var expr = pcex[d]
if (expr[0] === '=')
expr = expr.replace(brackets.R_STRINGS, function (qs) {
return qs

.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
})
return _bp[0] + expr
})
}
return html
Expand Down
13 changes: 12 additions & 1 deletion lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,11 @@ var compile = (function () {
if (expr[0] === '^')
expr = expr.slice(1)
else if (jsfn) {
var israw = expr[0] === '='
if (israw) expr = expr.slice(1)
expr = jsfn(expr, opts)
if (/;\s*$/.test(expr)) expr = expr.slice(0, expr.search(/;\s*$/))
if (israw) expr = '=' + expr
}
list[i] = '\u0001' + (pcex.push(expr.replace(/[\r\n]+/g, ' ').trim()) - 1) + _bp[1]
}
Expand All @@ -171,7 +174,15 @@ var compile = (function () {
if (pcex.length) {
html = html
.replace(/\u0001(\d+)/g, function (_, d) {
return _bp[0] + pcex[d]
var expr = pcex[d]
if (expr[0] === '=')
expr = expr.replace(brackets.R_STRINGS, function (qs) {
return qs
//.replace(/&/g, '&amp;') // I don't know if this make sense
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
})
return _bp[0] + expr
})
}
return html
Expand Down
2 changes: 1 addition & 1 deletion test/specs/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('Compile HTML', function() {
testStr("<p\ta ='p:{}\r\n;'>", '<p a="p:{} ;">')
})

it('double quotes in expressions are converted to `&quot;`', function () {
it('nested double quotes are supported in expressions', function () {
testStr('<p x={ "a" } y="{2}">', '<p x="{"a"}" y="{2}">')
testStr('<p x="{"a"}" y="{2}">', '<p x="{"a"}" y="{2}">')
testStr('<p x=\'{"a"}\' y="{2}">', '<p x="{"a"}" y="{2}">')
Expand Down

0 comments on commit bc56c6a

Please sign in to comment.