Updated tests

This commit is contained in:
Patrick Steele-Idem 2017-02-21 17:16:53 -07:00
parent 0eb586f82e
commit bc384549f6
100 changed files with 100 additions and 64 deletions

View File

@ -1,3 +1,3 @@
<div class="a"> <div class="b">
Hello ${state.name} Hello ${data.name}
</div> </div>

View File

@ -1,3 +1,3 @@
<div class="a"> <div class="b">
Hello ${data.name} Hello ${state.name}
</div> </div>

View File

@ -0,0 +1 @@
Hello Frank! Hello John!

View File

@ -0,0 +1,7 @@
<script template-helpers>
function greeting(name, out) {
out.write('Hello ' + name + '!');
}
</script>
<invoke greeting('Frank', out)/> <invoke greeting('John', out)/>

View File

@ -0,0 +1 @@
FRANK 3650 []

View File

@ -0,0 +1,3 @@
<var name='Frank' age=10 foo/>
-- ${name.toUpperCase()} ${age*365} [${foo}]

View File

@ -0,0 +1 @@
exports.templateData = {};

View File

@ -0,0 +1 @@
exports.templateData = {};

View File

@ -1,3 +1,4 @@
<var empty=""/> $ var empty="";
<img alt=""> <img alt="">
<img alt=empty> <img alt=empty>

View File

@ -1,4 +1,4 @@
var foo = { $ var foo = {
name: 'Frank', name: 'Frank',
toString: function() { toString: function() {
return this.name; return this.name;

View File

@ -1,2 +1,3 @@
var attrs={name: 'Frank'} $ var attrs={name: 'Frank'};
<test-hello ${attrs} adult=true/> <test-hello ${attrs} adult=true/>

View File

@ -1,2 +1,3 @@
var attrs={name: 'Frank', adult: true} $ var attrs={name: 'Frank', adult: true};
<test-hello ${attrs}/> <test-hello ${attrs}/>

View File

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

View File

@ -1,4 +1,4 @@
<var dynamic='<Frank>'/> $ var dynamic='<Frank>';
<ul> <ul>
<li> <li>

View File

@ -1,7 +1,7 @@
<script template-helpers> static {
var array1 = ['a', 'b', 'c']; var array1 = ['a', 'b', 'c'];
var array2 = ['red', 'green', 'blue']; var array2 = ['red', 'green', 'blue'];
</script> }
<var i item> <var i item>
<for(i=0; i<array1.length; i++)> <for(i=0; i<array1.length; i++)>

View File

@ -1,7 +1,7 @@
<script template-helpers> static {
var notEmpty = require('marko/helpers/notEmpty'); var notEmpty = require('marko/helpers/notEmpty');
var empty = require('marko/helpers/empty'); var empty = require('marko/helpers/empty');
</script> }
<div if(notEmpty(['a', 'b', 'c']))> <div if(notEmpty(['a', 'b', 'c']))>
notEmpty-YES notEmpty-YES

View File

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

View File

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

View File

@ -1 +1 @@
Hello Frank! Hello John! Hello Frank!Hello John!

View File

@ -1,7 +1,7 @@
<script template-helpers>
function greeting(name, out) { static function greeting(name, out) {
out.write('Hello ' + name + '!'); out.write('Hello ' + name + '!');
} }
</script>
<invoke greeting('Frank', out)/> <invoke greeting('John', out)/> $ greeting('Frank', out);
$ greeting('John', out);

View File

@ -1,8 +1,7 @@
--- static {
<script template-helpers>
var testHelpers = require('./test-helpers') var testHelpers = require('./test-helpers')
</script> }
---
Hello ${testHelpers.upperCase("world")}! Hello ${testHelpers.upperCase("world")}!
Hello ${testHelpers.trim(" World ")}! Hello ${testHelpers.trim(" World ")}!
--- ---

View File

@ -1,4 +1,4 @@
var basePath='/abc'; $ var basePath='/abc';
<script type="application/json"> <script type="application/json">
${JSON.stringify({ ${JSON.stringify({

View File

@ -1,4 +1,5 @@
<var a=4/> $ var a=4;
--- ---
<% a=10 %> <% a=10 %>
${a} ${a}

View File

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

View File

@ -1,2 +1,3 @@
var a = 1, b = 1 + 1, c = 4 - 1, d = 'a' instanceof Boolean, e = 5 * 5 + 5 - 2 / 2, f = typeof 'foo' === 'string'; var a = 1, b = 1 + 1, c = 4 - 1, d = 'a' instanceof Boolean, e = 5 * 5 + 5 - 2 / 2, f = typeof 'foo' === 'string';
<div>${a},${b},${c},${d},${e},${f}</div> <div>${a},${b},${c},${d},${e},${f}</div>

View File

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

View File

@ -1,4 +1,4 @@
<var tabs=input.tabs/> $ var tabs=input.tabs;
<div class="tabs"> <div class="tabs">
<ul> <ul>
@ -8,7 +8,11 @@
</ul> </ul>
<div class="tab-content"> <div class="tab-content">
<div class="tab" for(tab in tabs)> <div class="tab" for(tab in tabs)>
<invoke tab.renderBody(out) if(tab.renderBody)/> $ {
if(tab.renderBody) {
tab.renderBody(out);
}
}
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,5 +1,5 @@
var pageTitle="Marko Templating Engine" $ var pageTitle="Marko Templating Engine"
var currentPage='home' $ var currentPage='home'
<!DOCTYPE html> <!DOCTYPE html>
html lang="en" html lang="en"

View File

@ -1,4 +1,4 @@
<var tabs=input.tabs/> $ var tabs=input.tabs;
<div class="tabs"> <div class="tabs">
<ul> <ul>
@ -8,7 +8,11 @@
</ul> </ul>
<div class="tab-content"> <div class="tab-content">
<div class="tab" for(tab in tabs)> <div class="tab" for(tab in tabs)>
<invoke tab.renderBody(out) if(tab.renderBody)/> $ {
if (tab.renderBody) {
tab.renderBody(out);
}
}
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,5 +1,5 @@
<var pageTitle="Marko Templating Engine"/> $ var pageTitle="Marko Templating Engine";
<var currentPage='home'/> $ var currentPage='home';
<!DOCTYPE html> <!DOCTYPE html>
html lang="en" html lang="en"

View File

@ -1,4 +1,4 @@
<var tabs=input.tabs/> $ var tabs=input.tabs;
<div class="tabs"> <div class="tabs">
<ul> <ul>
@ -8,7 +8,11 @@
</ul> </ul>
<div class="tab-content"> <div class="tab-content">
<div class="tab" for(tab in tabs)> <div class="tab" for(tab in tabs)>
<invoke tab.renderBody(out) if(tab.renderBody)/> $ {
if(tab.renderBody) {
tab.renderBody(out) ;
}
}
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,5 +1,5 @@
<var pageTitle="Marko Templating Engine"/> $ var pageTitle="Marko Templating Engine";
<var currentPage='home'/> $ var currentPage='home';
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">

View File

@ -1,4 +1,4 @@
<var tabs=input.tabs/> $ var tabs=input.tabs;
<div class="tabs"> <div class="tabs">
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
@ -10,7 +10,11 @@
</ul> </ul>
<div class="tab-content"> <div class="tab-content">
<div id=tab.id class=tab.divClass for(tab in tabs)> <div id=tab.id class=tab.divClass for(tab in tabs)>
<invoke tab.renderBody(out) if(tab.renderBody) /> $ {
if(tab.renderBody) {
tab.renderBody(out);
}
}
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,4 +1,4 @@
<var showConditionalTab=input.showConditionalTab/> $ var showConditionalTab=input.showConditionalTab;
<test-tabs-new> <test-tabs-new>
<test-tab-new title="Tab 1"> <test-tab-new title="Tab 1">

View File

@ -1,4 +1,4 @@
<var tabs=input.tabs/> $ var tabs=input.tabs;
<div class="tabs"> <div class="tabs">
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
@ -10,7 +10,7 @@
</ul> </ul>
<div class="tab-content"> <div class="tab-content">
<div id=tab.id class=tab.divClass for(tab in tabs)> <div id=tab.id class=tab.divClass for(tab in tabs)>
<invoke tab.renderBody(out) /> $ tab.renderBody(out);
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,4 +1,4 @@
<var showConditionalTab=input.showConditionalTab/> $ var showConditionalTab=input.showConditionalTab;
<test-tabs> <test-tabs>
<test-tab title="Tab 1"> <test-tab title="Tab 1">

View File

@ -1 +1 @@
Hello John. You are from San Jose, CA Zero: 0 Hello John. You are from San Jose, CA Zero: 0

View File

@ -1,5 +1,4 @@
$ var person=input.person;
--- ---
<var person=input.person/>
Hello ${person.name}. You are from ${person.address.city}, ${person.address.state} Zero: ${input.zero} Hello ${person.name}. You are from ${person.address.city}, ${person.address.state} Zero: ${input.zero}
--- ---

View File

@ -1,4 +1,4 @@
var foo = { $ var foo = {
toString: function() { toString: function() {
return 'bar'; return 'bar';
} }

View File

@ -1,11 +1,11 @@
<var colors=['red', 'green', 'blue']/> $ var colors=['red', 'green', 'blue']
<div for(color in colors)> <div for(color in colors)>
${color} ${color}
</div> </div>
<assign colors=['orange', 'purple', 'yellow']/> $ colors=['orange', 'purple', 'yellow'];
<div for(color in colors)> <div for(color in colors)>
${color} ${color}

View File

@ -1,3 +1,3 @@
var date = new Date('Sat Jan 01 2000 00:00:00 GMT+0000 (UTC)'); $ var date = new Date('Sat Jan 01 2000 00:00:00 GMT+0000 (UTC)');
<div>${date.toISOString()}</div> <div>${date.toISOString()}</div>

View File

@ -1,2 +1,2 @@
var a = 1, b = 2; $ var a = 1, b = 2;
<div>${a},${b}</div> <div>${a},${b}</div>

View File

@ -1,3 +1,3 @@
<var name='Frank' age=10 foo/> $ var name='Frank', age=10, foo;
-- ${name.toUpperCase()} ${age*365} [${foo}] -- ${name.toUpperCase()} ${age*365} [${foo}]

View File

@ -1,3 +1,3 @@
var n=0 $ var n=0
ul ul
li while(n < 4) -- ${n++} li while(n < 4) -- ${n++}

View File

@ -1,4 +1,4 @@
var n=0 $ var n=0
ul ul
while(n < 4) while(n < 4)
li -- ${n++} li -- ${n++}