mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
Don't escape for $!{}
This commit is contained in:
parent
257dd1f5c4
commit
8263c6aad4
@ -20,10 +20,7 @@ function isIEConditionalComment(comment) {
|
|||||||
return ieConditionalCommentRegExp.test(comment);
|
return ieConditionalCommentRegExp.test(comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseExpression(expression) {
|
var parseExpression = require('./util/parseExpression');
|
||||||
// TODO Build an AST from the String expression
|
|
||||||
return expression;
|
|
||||||
}
|
|
||||||
|
|
||||||
class Parser {
|
class Parser {
|
||||||
constructor(parserImpl) {
|
constructor(parserImpl) {
|
||||||
@ -122,7 +119,7 @@ class Parser {
|
|||||||
name: attr.name,
|
name: attr.name,
|
||||||
value: isLiteral ?
|
value: isLiteral ?
|
||||||
builder.literal(attr.literalValue) :
|
builder.literal(attr.literalValue) :
|
||||||
parseExpression(attr.expression)
|
attr.expression == null ? undefined : parseExpression(attr.expression)
|
||||||
};
|
};
|
||||||
|
|
||||||
if (attr.argument) {
|
if (attr.argument) {
|
||||||
@ -171,9 +168,11 @@ class Parser {
|
|||||||
handleBodyTextPlaceholder(expression, escape) {
|
handleBodyTextPlaceholder(expression, escape) {
|
||||||
this.prevTextNode = null;
|
this.prevTextNode = null;
|
||||||
|
|
||||||
|
var parsedExpression = parseExpression(expression);
|
||||||
|
|
||||||
var builder = this.context.builder;
|
var builder = this.context.builder;
|
||||||
|
|
||||||
var text = builder.text(expression, escape);
|
var text = builder.text(parsedExpression, escape);
|
||||||
this.parentNode.appendChild(text);
|
this.parentNode.appendChild(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -49,11 +49,13 @@ class Text extends Node {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let builder = codegen.builder;
|
let builder = codegen.builder;
|
||||||
|
if (this.escape !== false) {
|
||||||
// TODO Only escape if necessary
|
// TODO Only escape the parts that need to be escaped if it is a compound expression with static
|
||||||
argument = builder.functionCall(
|
// text parts
|
||||||
'escapeXml',
|
argument = builder.functionCall(
|
||||||
[argument]);
|
'escapeXml',
|
||||||
|
[argument]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
codegen.addWrite(argument);
|
codegen.addWrite(argument);
|
||||||
|
|||||||
@ -1 +0,0 @@
|
|||||||
<span>Welcome</span><span>Welcome</span><span>Welcome</span> <Patrick><div title="<span>Welcome</span> <hello>" data-name="<Patrick>"></div><div data-attr="Hello <Patrick> <hello>" data-nested-attr="<Hello> <Patrick> <hello>" data-nested-attr2="Hello <John> <hello>">Hello <John>© <hello> <START></div>
|
|
||||||
@ -1,16 +0,0 @@
|
|||||||
<var name="name" value="data.name"/>
|
|
||||||
<var name="welcome" value="data.welcome"/>
|
|
||||||
|
|
||||||
$!welcome
|
|
||||||
$!{welcome}
|
|
||||||
${xml:welcome}
|
|
||||||
$name
|
|
||||||
|
|
||||||
<div title="$welcome <hello>" data-name="$name"/>
|
|
||||||
|
|
||||||
<div data-attr="Hello $name <hello>">
|
|
||||||
<attr name="data-nested-attr"><Hello> $name <![CDATA[<hello>]]></attr>
|
|
||||||
<attr name="data-nested-attr2" value="Hello <John> <hello>"/>
|
|
||||||
Hello <John>© <![CDATA[<hello>]]>
|
|
||||||
${startTag:START}
|
|
||||||
</div>
|
|
||||||
1
test/fixtures/render/autotest/xml-escaping/expected.html
vendored
Normal file
1
test/fixtures/render/autotest/xml-escaping/expected.html
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
<span>Welcome</span><Patrick>
|
||||||
2
test/fixtures/render/autotest/xml-escaping/template.marko
vendored
Normal file
2
test/fixtures/render/autotest/xml-escaping/template.marko
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
$!{data.welcome}
|
||||||
|
${data.name}
|
||||||
Loading…
x
Reference in New Issue
Block a user