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);
|
||||
}
|
||||
|
||||
function parseExpression(expression) {
|
||||
// TODO Build an AST from the String expression
|
||||
return expression;
|
||||
}
|
||||
var parseExpression = require('./util/parseExpression');
|
||||
|
||||
class Parser {
|
||||
constructor(parserImpl) {
|
||||
@ -122,7 +119,7 @@ class Parser {
|
||||
name: attr.name,
|
||||
value: isLiteral ?
|
||||
builder.literal(attr.literalValue) :
|
||||
parseExpression(attr.expression)
|
||||
attr.expression == null ? undefined : parseExpression(attr.expression)
|
||||
};
|
||||
|
||||
if (attr.argument) {
|
||||
@ -171,9 +168,11 @@ class Parser {
|
||||
handleBodyTextPlaceholder(expression, escape) {
|
||||
this.prevTextNode = null;
|
||||
|
||||
var parsedExpression = parseExpression(expression);
|
||||
|
||||
var builder = this.context.builder;
|
||||
|
||||
var text = builder.text(expression, escape);
|
||||
var text = builder.text(parsedExpression, escape);
|
||||
this.parentNode.appendChild(text);
|
||||
}
|
||||
|
||||
|
||||
@ -49,11 +49,13 @@ class Text extends Node {
|
||||
}
|
||||
} else {
|
||||
let builder = codegen.builder;
|
||||
|
||||
// TODO Only escape if necessary
|
||||
argument = builder.functionCall(
|
||||
'escapeXml',
|
||||
[argument]);
|
||||
if (this.escape !== false) {
|
||||
// TODO Only escape the parts that need to be escaped if it is a compound expression with static
|
||||
// text parts
|
||||
argument = builder.functionCall(
|
||||
'escapeXml',
|
||||
[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