Fixes #549 - Migrate from "data" to "input"

This commit is contained in:
Patrick Steele-Idem 2017-01-26 17:18:12 -07:00
parent 96a360e515
commit 489321cf54
178 changed files with 277 additions and 268 deletions

View File

@ -38,7 +38,9 @@ class TemplateRoot extends Node {
var builder = codegen.builder;
let renderStatements = [];
let renderStatements = [
builder.var('data', builder.identifier('input'))
];
var vars = createVarsArray(context.getVars());
if (vars.length) {
renderStatements.push(builder.vars(vars));
@ -56,7 +58,7 @@ class TemplateRoot extends Node {
builder.functionDeclaration(
null,
[
builder.identifier('data'),
builder.identifier('input'),
builder.identifierOut()
],
renderStatements)
@ -89,7 +91,7 @@ class TemplateRoot extends Node {
body = body.concat(staticNodes);
}
var renderParams = [builder.identifier('data'), builder.identifierOut()];
var renderParams = [builder.identifier('input'), builder.identifierOut()];
if (this.extraRenderParams) {
renderParams = renderParams.concat(this.extraRenderParams);
}

View File

@ -0,0 +1 @@
Hello Frank! data===input ? true

View File

@ -0,0 +1 @@
-- Hello ${data.name}! data===input ? ${data === input}

View File

@ -0,0 +1,3 @@
exports.templateData = {
name: 'Frank'
};

View File

@ -1,5 +1,5 @@
<select multiple>
<option value="red">Red</option>
<option value="green" selected=(data.isGreenSelected)>Green</option>
<option value="blue" selected=(data.isBlueSelected)>Blue</option>
<option value="green" selected=(input.isGreenSelected)>Green</option>
<option value="blue" selected=(input.isBlueSelected)>Blue</option>
</select>

View File

@ -1,11 +1,11 @@
<input type="checkbox" checked=data.checked>
<input type="checkbox" checked=input.checked>
<button disabled>Button</button>
<select>
<option value="${option.value}"
selected=option.selected
for(option in data.options)>
for(option in input.options)>
${option.value}

View File

@ -1 +1 @@
<img alt=(data.myAlt || true)>
<img alt=(input.myAlt || true)>

View File

@ -1 +1 @@
<div value=data.myObject/>
<div value=input.myObject/>

View File

@ -1,3 +1,3 @@
<div foo='Hello ${data.foo || ''}'>
<div foo='Hello ${input.foo || ''}'>
Hello World!
</div>

View File

@ -1,3 +1,3 @@
<div foo='Hello $!{data.foo || ''}'>
<div foo='Hello $!{input.foo || ''}'>
Hello World!
</div>

View File

@ -1 +1 @@
<div data-_onclick=data.parent/>
<div data-_onclick=input.parent/>

View File

@ -1 +1 @@
<div data-_onclick=data.specialData/>
<div data-_onclick=input.specialData/>

View File

@ -1,3 +1,3 @@
<div ${data.myAttrs} data-encoding='"hello"'>
<div ${input.myAttrs} data-encoding='"hello"'>
Hello World!
</div>

View File

@ -1,6 +1,6 @@
<div class="hello">
<h1>test-hello</h1>
<div class="body">
<invoke data.renderBody(out) />
<invoke input.renderBody(out) />
</div>
</div>

View File

@ -1,6 +1,6 @@
<a href=data.url body-only-if(!data.url)>
<a href=input.url body-only-if(!input.url)>
Some Link
</a>
<a href=data.invalidUrl body-only-if(!data.invalidUrl)>
<a href=input.invalidUrl body-only-if(!input.invalidUrl)>
Another Link
</a>

View File

@ -1,5 +1,5 @@
<ul>
<li for(item in data.items)>
<li for(item in input.items)>
<b>${item.label}</b>
<navigation-item items=item.children if(item.children)/>
</li>

View File

@ -1 +1 @@
<navigation-item items=data.items/>
<navigation-item items=input.items/>

View File

@ -1,6 +1,6 @@
div -- Hello ${data.name}
<span if(data.name)>
${data.name}
div -- Hello ${input.name}
<span if(input.name)>
${input.name}
</span>
<p else>
No name!

View File

@ -1,4 +1,4 @@
div -- Hello ${data.name}
span if(data.name)
-- ${data.name}
div -- Hello ${input.name}
span if(input.name)
-- ${input.name}
p else -- No name!

View File

@ -1,3 +1,3 @@
<div class=( false ? 'some-class' : undefined )></div>
<div class=( true ? 'some-class' : false )></div>
<div class=data.name></div>
<div class=input.name></div>

View File

@ -1,3 +1,3 @@
---
Hello ${data.name}!
Hello ${input.name}!
---

View File

@ -1,3 +1,3 @@
---
Hello ${data.name}!
Hello ${input.name}!
---

View File

@ -1 +1 @@
<div ${data.attrs}>Hello World</div>
<div ${input.attrs}>Hello World</div>

View File

@ -1,5 +1,5 @@
hello-${data.myTagName} class="my-class" foo="bar"
hello-${input.myTagName} class="my-class" foo="bar"
-- My nested content
${data.foo ? 'foo' : 'bar'} class="my-class" foo="bar"
${input.foo ? 'foo' : 'bar'} class="my-class" foo="bar"
-- My nested content

View File

@ -1,7 +1,7 @@
<hello-${data.myTagName} class="my-class" foo="bar">
<hello-${input.myTagName} class="my-class" foo="bar">
My nested content
</>
<${data.foo ? 'foo' : 'bar'} class="my-class" foo="bar">
<${input.foo ? 'foo' : 'bar'} class="my-class" foo="bar">
My nested content
</>

View File

@ -1,6 +1,6 @@
p
<span>
<a>
Hello ${data.name}!
Hello ${input.name}!
</>
</>

View File

@ -1,4 +1,4 @@
<div if(data.foo === dasda 0)>
<div if(input.foo === dasda 0)>
A
</div>
<div else>

View File

@ -5,5 +5,5 @@ exports.templateData = {};
exports.checkError = function(e) {
var message = e.toString();
// expect(message).to.contain('Error: Unable to compile template at path');
expect(message).to.contain('Unexpected number: (data.foo === dasda 0)');
expect(message).to.contain('Unexpected number: (input.foo === dasda 0)');
};

View File

@ -1,4 +1,4 @@
<div if(data.foo === 0)>
<div if(input.foo === 0)>
A
</div>
<div else-if(true sds)>

View File

@ -1,7 +1,7 @@
<div if(data.foo === 0)>
<div if(input.foo === 0)>
A
</div>
<div else-if(data.foo ==== 1)>
<div else-if(input.foo ==== 1)>
B
</div>
<div else foo asasa sasa>

View File

@ -4,5 +4,5 @@ exports.templateData = {};
exports.checkError = function(e) {
var message = e.toString();
expect(message).to.contain('Unexpected token =: (data.foo ==== 1)');
expect(message).to.contain('Unexpected token =: (input.foo ==== 1)');
};

View File

@ -1,4 +1,4 @@
<script>
var foo = ${JSON.stringify(data.foo)};
var foo = ${JSON.stringify(input.foo)};
</script>
<pre>${JSON.stringify(data.foo)}</pre>
<pre>${JSON.stringify(input.foo)}</pre>

View File

@ -1,3 +1,3 @@
<for(item in data.myIterator)>
<for(item in input.myIterator)>
${item}
</for>

View File

@ -1,3 +1,3 @@
<div for(item in ['a', 'b', 'c'] | iterator=data.reverseIterator)>
<div for(item in ['a', 'b', 'c'] | iterator=input.reverseIterator)>
${item}
</div>

View File

@ -1,3 +1,3 @@
<div for(item in ['a', 'b', 'c'] | iterator=data.reverseIterator status-var=status )>
<div for(item in ['a', 'b', 'c'] | iterator=input.reverseIterator status-var=status )>
${status.index}-${item}
</div>

View File

@ -1,3 +1,3 @@
<for (item in ['a', 'b', 'c'] | iterator=data.reverseIterator status-var=status )>
<for (item in ['a', 'b', 'c'] | iterator=input.reverseIterator status-var=status )>
${status.index}-${item}
</for>

View File

@ -1,3 +1,3 @@
<for(item in ['a', 'b', 'c'] | iterator=data.reverseIterator)>
<for(item in ['a', 'b', 'c'] | iterator=input.reverseIterator)>
${item}
</for>

View File

@ -1,3 +1,3 @@
<for(name,value in data.myMap)>
<for(name,value in input.myMap)>
[${name}=${value}]
</for>

View File

@ -1,4 +1,4 @@
<for(color in data.colors | array)>
<for(color in input.colors | array)>
<div>
${color}
</div>

View File

@ -1,5 +1,5 @@
function getName() {
return data.firstName + ' ' + data.lastName;
return input.firstName + ' ' + input.lastName;
}
-- Hello ${getName()}

View File

@ -1 +1 @@
-- Hello ${data.name}! Hello $!{data.name}! Hello $!{data.missing}!
-- Hello ${input.name}! Hello $!{input.name}! Hello $!{input.missing}!

View File

@ -1,4 +1,4 @@
<div if(data.foo === 0)>
<div if(input.foo === 0)>
A
</div>
<div else>

View File

@ -1,4 +1,4 @@
<div if(data.foo === 0)>
<div if(input.foo === 0)>
A
</div>
<div else-if(true)>

View File

@ -1,7 +1,7 @@
<div if(data.foo === 0)>
<div if(input.foo === 0)>
A
</div>
<div else-if(data.foo === 1)>
<div else-if(input.foo === 1)>
B
</div>
<div else>

View File

@ -1 +1 @@
-- Hello ${data.name}! You have ${data.count} new messages.
-- Hello ${input.name}! You have ${input.count} new messages.

View File

@ -1,9 +1,9 @@
<div>
<h1>
Hello ${data.name}! You have ${data.count} new messages.
Hello ${input.name}! You have ${input.count} new messages.
</h1>
<p if(data.renderBody)>
<invoke data.renderBody(out)/>
<p if(input.renderBody)>
<invoke input.renderBody(out)/>
</p>
<p else>
No body!

View File

@ -1,8 +1,8 @@
<div>
<h1>
Hello ${data.name}! You have ${data.count} new messages.
Hello ${input.name}! You have ${input.count} new messages.
</h1>
<p>
<invoke data.renderBody(out)/>
<invoke input.renderBody(out)/>
</p>
</div>

View File

@ -1 +1 @@
<include(data.component, {name: 'Frank'})/>
<include(input.component, {name: 'Frank'})/>

View File

@ -1,8 +1,8 @@
<div>
<h1>
Hello ${data.name}! You have ${data.count} new messages.
Hello ${input.name}! You have ${input.count} new messages.
</h1>
<p>
<invoke data.renderBody(out)/>
<invoke input.renderBody(out)/>
</p>
</div>

View File

@ -1 +1 @@
-- Hello ${data.name}! You have ${data.count} new messages.
-- Hello ${input.name}! You have ${input.count} new messages.

View File

@ -1 +1 @@
-- Hello ${data.name}! You have ${data.count} new messages.
-- Hello ${input.name}! You have ${input.count} new messages.

View File

@ -1 +1 @@
<include(data.includeTarget) name='Frank' count=20/>
<include(input.includeTarget) name='Frank' count=20/>

View File

@ -1 +1 @@
-- Hello ${data.firstName} ${data.lastName}!
-- Hello ${input.firstName} ${input.lastName}!

View File

@ -1 +1 @@
-- Hello ${data.firstName}! You have ${data.count} new messages.
-- Hello ${input.firstName}! You have ${input.count} new messages.

View File

@ -1,17 +1,17 @@
<h1 if(data.showHeader !== false)>
<if(data.header)>
<include(data.header)/>
<h1 if(input.showHeader !== false)>
<if(input.header)>
<include(input.header)/>
</if>
<else>
DEFAULT TITLE
</else>
</h1>
<div>
<include(data.body)/>
<include(input.body)/>
</div>
<h1 if(data.showFooter !== false)>
<if(data.footer)>
<include(data.footer)/>
<h1 if(input.showFooter !== false)>
<if(input.footer)>
<include(input.footer)/>
</if>
<else>
DEFAULT FOOTER

View File

@ -1,13 +1,13 @@
<h1 if(data.showHeader !== false)>
<if(data.header)>
<include(data.header)/>
<h1 if(input.showHeader !== false)>
<if(input.header)>
<include(input.header)/>
</if>
<else>
DEFAULT TITLE
</else>
</h1>
<div>
<include(data.body)/>
<include(input.body)/>
</div>
<include(data.footer)/>
<include(data.empty)/>
<include(input.footer)/>
<include(input.empty)/>

View File

@ -1,13 +1,13 @@
<h1 if(data.showHeader !== false)>
<if(data.header)>
<include(data.header)/>
<h1 if(input.showHeader !== false)>
<if(input.header)>
<include(input.header)/>
</if>
<else>
DEFAULT TITLE
</else>
</h1>
<div>
<include(data.body)/>
<include(input.body)/>
</div>
<include(data.footer)/>
<include(data.empty)/>
<include(input.footer)/>
<include(input.empty)/>

View File

@ -12,7 +12,7 @@
<@body>BODY CONTENT</@body>
<@footer>FOOTER CONTENT</@footer>
</include>
<include(data.layoutDynamic) show-header=true>
<include(input.layoutDynamic) show-header=true>
<@body>BODY CONTENT</@body>
<@footer>FOOTER CONTENT</@footer>
</include>

View File

@ -1 +1 @@
<include(data.renderBody, {name: 'Frank'}) age=10/>
<include(input.renderBody, {name: 'Frank'}) age=10/>

View File

@ -1 +1 @@
<include(data.renderBody)/>
<include(input.renderBody)/>

View File

@ -1 +1 @@
<include(data.renderBody, 'Frank')/>
<include(input.renderBody, 'Frank')/>

View File

@ -1 +1 @@
<include(data.renderBody, {name: 'Frank'})/>
<include(input.renderBody, {name: 'Frank'})/>

View File

@ -1,8 +1,8 @@
<div>
<h1>
Hello ${data.name}! You have ${data.count} new messages.
Hello ${input.name}! You have ${input.count} new messages.
</h1>
<p>
<invoke data.renderBody(out)/>
<invoke input.renderBody(out)/>
</p>
</div>

View File

@ -1 +1 @@
-- Hello ${data.name}! You have ${data.count} new messages.
-- Hello ${input.name}! You have ${input.count} new messages.

View File

@ -1,4 +1,4 @@
<var name="name" value="data.name"/>
<var name="name" value="input.name"/>
<html>
<head>
@ -10,7 +10,7 @@
<script type="text/javascript">
<div if(foo)></div>
$(function() {
alert('${data.name}');
alert('${input.name}');
})
</script>
</body>

View File

@ -1,5 +1,5 @@
<div marko-body="parsed-text">
<span if(foo)>
Hello ${data.name}!
Hello ${input.name}!
</span>
</div>

View File

@ -1,11 +1,11 @@
<div class="message">
<h1>
<include(data.title)/>
<include(input.title)/>
</h1>
<div>
<include(data.body)/>
<include(input.body)/>
</div>
<div>
<include(data.renderBody)/>
<include(input.renderBody)/>
</div>
</div>

View File

@ -1,5 +1,5 @@
<ul>
<li for(item in data.items)>
<li for(item in input.items)>
<h1>${item.title}</h1>
<include(item.renderBody)/>
</li>

View File

@ -1,8 +1,8 @@
<div class="message">
<h1>
<include(data.title)/>
<include(input.title)/>
</h1>
<div>
<include(data.body)/>
<include(input.body)/>
</div>
</div>

View File

@ -1,8 +1,8 @@
<div class="message">
<h1>
<include(data.title)/>
<include(input.title)/>
</h1>
<div>
<include(data.body)/>
<include(input.body)/>
</div>
</div>

View File

@ -1,8 +1,8 @@
<div class="message">
<h1>
<b>${data.header.label}:</b> <include(data.header)/>
<b>${input.header.label}:</b> <include(input.header)/>
</h1>
<div>
<b>${data.body.label}:</b> <include(data.body)/>
<b>${input.body.label}:</b> <include(input.body)/>
</div>
</div>

View File

@ -1,8 +1,8 @@
<div class="message">
<h1>
<b>${data.header.label}:</b> <include(data.header)/>
<b>${input.header.label}:</b> <include(input.header)/>
</h1>
<div>
<b>${data.body.label}:</b> <include(data.body)/>
<b>${input.body.label}:</b> <include(input.body)/>
</div>
</div>

View File

@ -1,5 +1,5 @@
<ul>
<li for(item in data.items)>
<li for(item in input.items)>
<h1>${item.title}</h1>
<include(item.renderBody)/>
</li>

View File

@ -1,5 +1,5 @@
<ul>
<li for(item in data.items)>
<li for(item in input.items)>
<h1>${item.title}</h1>
<include(item.renderBody)/>
</li>

View File

@ -1,8 +1,8 @@
<div class="message">
<h1>
${data.title.label}: <include(data.title)/>
${input.title.label}: <include(input.title)/>
</h1>
<div>
${data.body.label}: <include(data.body)/>
${input.body.label}: <include(input.body)/>
</div>
</div>

View File

@ -1,4 +1,4 @@
<var tabs=data.tabs/>
<var tabs=input.tabs/>
<div class="tabs">
<ul>

View File

@ -1,4 +1,4 @@
<div for(item in data.items)>
<div for(item in input.items)>
Foo: ${item.foo}
Body: <invoke item.body.renderBody(out) if(item.body)/>
</div>

View File

@ -1,4 +1,4 @@
<var tabs=data.tabs/>
<var tabs=input.tabs/>
<div class="tabs">
<ul>

View File

@ -1,13 +1,13 @@
<div class="overlay">
<div class="overlay-header ${data.header.className || ''}" if(data.header)>
<invoke data.header.renderBody(out)/>
<div class="overlay-header ${input.header.className || ''}" if(input.header)>
<invoke input.header.renderBody(out)/>
</div>
<div class="overlay-body ${data.body.className}" if(data.body)>
<invoke data.body.renderBody(out)/>
<div class="overlay-body ${input.body.className}" if(input.body)>
<invoke input.body.renderBody(out)/>
</div>
<div class="overlay-footer ${data.footer.className}" if(data.footer)>
<invoke data.footer.renderBody(out)/>
<div class="overlay-footer ${input.footer.className}" if(input.footer)>
<invoke input.footer.renderBody(out)/>
</div>
</div>

View File

@ -1,4 +1,4 @@
<test-nested-tags-overlay header=data.header>
<test-nested-tags-overlay header=input.header>
<test-nested-tags-overlay:body class="my-body">
Body content

View File

@ -1,4 +1,4 @@
<var tabs=data.tabs/>
<var tabs=input.tabs/>
<div class="tabs">
<ul>

View File

@ -1,4 +1,4 @@
<var tabs=data.tabs/>
<var tabs=input.tabs/>
<div class="tabs">
<ul>

View File

@ -1,13 +1,13 @@
<div class="overlay">
<div class="overlay-header" if(data.header)>
<invoke data.header.renderBody(out)/>
<div class="overlay-header" if(input.header)>
<invoke input.header.renderBody(out)/>
</div>
<div class="overlay-body ${data.body.className}" if(data.body)>
<invoke data.body.renderBody(out)/>
<div class="overlay-body ${input.body.className}" if(input.body)>
<invoke input.body.renderBody(out)/>
</div>
<div class="overlay-footer ${data.footer.className}" if(data.footer)>
<invoke data.footer.renderBody(out)/>
<div class="overlay-footer ${input.footer.className}" if(input.footer)>
<invoke input.footer.renderBody(out)/>
</div>
</div>

View File

@ -1,4 +1,4 @@
<test-nested-tags-overlay header=data.header>
<test-nested-tags-overlay header=input.header>
<test-nested-tags-overlay:body class="my-body">
Body content

View File

@ -1,3 +1,3 @@
<my-custom-tag short="World"/>
-- Hello ${data.short}
-- Hello ${input.short}

View File

@ -1,3 +1,3 @@
---
scanned-b: Hello ${data.name}
scanned-b: Hello ${input.name}
---

View File

@ -9,5 +9,5 @@ TAG = {
}
-->
---
scanned-d: Hello ${data.NAME}
scanned-d: Hello ${input.NAME}
---

View File

@ -1,3 +1,3 @@
<script foo="bar" ${data.myAttrs} csp-nonce>
<script foo="bar" ${input.myAttrs} csp-nonce>
console.log('foo')
</script>

View File

@ -1 +1 @@
<script>document.write('<div>Hello ${data.name}</div>');</script>
<script>document.write('<div>Hello ${input.name}</div>');</script>

View File

@ -1 +1 @@
div.foo.${data.missing} class="baz"
div.foo.${input.missing} class="baz"

View File

@ -1,3 +1,3 @@
.foo.bar.baz.bat
.foo.bar.${data.cls}.baz
.foo.bar.${input.cls}.baz
.foo.bar.baz class="test"

View File

@ -1,2 +1,2 @@
div#foo-${data.name} style="color: red;"
-- Hello ${data.name}!
div#foo-${input.name} style="color: red;"
-- Hello ${input.name}!

View File

@ -1,2 +1,2 @@
div#foo style="color: red;"
-- Hello ${data.name}!
-- Hello ${input.name}!

View File

@ -1,2 +1,2 @@
div.foo style="color: red;"
-- Hello ${data.name}!
-- Hello ${input.name}!

View File

@ -1,3 +1,3 @@
<#foo.bar.baz>
Hello ${data.name}!
Hello ${input.name}!
</>

View File

@ -1,4 +1,4 @@
<var name=data.name count=data.count/>
<var name=input.name count=input.count/>
<div class=( count>50 ? 'over-50' : null)></div>
<div class=( count<50 ? 'under-50' : null)></div>

View File

@ -1,6 +1,6 @@
<var rootClass=data.rootClass
colors=data.colors
message=data.message />
<var rootClass=input.rootClass
colors=input.colors
message=input.message />
<div class="hello-world ${rootClass}">
${message}

View File

@ -1,2 +1,2 @@
<var name=data.name count=data.count/>
<var name=input.name count=input.count/>
-- ${name != null ? "Hello ${name.toUpperCase()}! You have ${count} new messages." : null}

View File

@ -1 +1 @@
div style=data.style
div style=input.style

View File

@ -1,4 +1,4 @@
<var tabs=data.tabs/>
<var tabs=input.tabs/>
<div class="tabs">
<ul>

Some files were not shown because too many files have changed in this diff Show More