mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
Marko v3: Added more complete syntax tests
This commit is contained in:
parent
4ca4ce9f37
commit
db4949dcfb
4
test/fixtures/render/autotest/syntax-concise/expected.html
vendored
Normal file
4
test/fixtures/render/autotest/syntax-concise/expected.html
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<!DOCTYPE html> <html lang="en"><head><title>Marko Templating Engine</title></head><body><h1>Marko Templating Engine</h1><p>Marko is a <i>fast</i> and lightweight templating engine that compiles templates to CommonJS modules and supports streaming, async rendering and custom tags. It supports both a familiar HTML syntax and a concise, indentation-based syntax.</p><ul class="features"><li>async</li><li>streaming</li><li>custom-tags</li><li>readable</li><li>modules</li></ul><div>No colors!</div><div class="tabs"><ul><li>Tab 1</li><li>Tab 2</li></ul><div class="tab-content"><div class="tab">Body content for Tab 1</div><div class="tab">Body content for Tab 2</div></div></div><script type="text/javascript">if (foo) {
|
||||||
|
alert('Marko is awesome!');
|
||||||
|
}
|
||||||
|
</script><ul><li><a class="nav-link active" href="/">Home</a></li><li><a class="nav-link" href="/docs">Docs</a></li><li><a class="nav-link" href="/blog">Blog</a></li></ul></body></html>
|
||||||
3
test/fixtures/render/autotest/syntax-concise/marko.json
vendored
Normal file
3
test/fixtures/render/autotest/syntax-concise/marko.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"<tabs>": "./tabs/marko-tag.json"
|
||||||
|
}
|
||||||
7
test/fixtures/render/autotest/syntax-concise/tabs/marko-tag.json
vendored
Normal file
7
test/fixtures/render/autotest/syntax-concise/tabs/marko-tag.json
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"renderer": "./renderer",
|
||||||
|
"@orientation": "string",
|
||||||
|
"@tabs <tab>[]": {
|
||||||
|
"@title": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
9
test/fixtures/render/autotest/syntax-concise/tabs/renderer.js
vendored
Normal file
9
test/fixtures/render/autotest/syntax-concise/tabs/renderer.js
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
var template =require('./template.marko');
|
||||||
|
|
||||||
|
exports.renderer = function(input, out) {
|
||||||
|
var tabs = input.tabs;
|
||||||
|
|
||||||
|
template.render({
|
||||||
|
tabs: tabs
|
||||||
|
}, out);
|
||||||
|
};
|
||||||
14
test/fixtures/render/autotest/syntax-concise/tabs/template.marko
vendored
Normal file
14
test/fixtures/render/autotest/syntax-concise/tabs/template.marko
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<var tabs=data.tabs/>
|
||||||
|
|
||||||
|
<div class="tabs">
|
||||||
|
<ul>
|
||||||
|
<li for(tab in tabs)>
|
||||||
|
${tab.title}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<div class="tab-content">
|
||||||
|
<div class="tab" for(tab in tabs)>
|
||||||
|
<invoke tab.renderBody(out) if(tab.renderBody)/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
48
test/fixtures/render/autotest/syntax-concise/template.marko
vendored
Normal file
48
test/fixtures/render/autotest/syntax-concise/template.marko
vendored
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
var pageTitle="Marko Templating Engine"
|
||||||
|
var currentPage='home'
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
html lang="en"
|
||||||
|
head
|
||||||
|
title - ${pageTitle}
|
||||||
|
body
|
||||||
|
h1 - ${pageTitle}
|
||||||
|
|
||||||
|
p
|
||||||
|
---
|
||||||
|
Marko is a <i>fast</i> and lightweight templating engine that
|
||||||
|
compiles templates to CommonJS modules and supports streaming,
|
||||||
|
async rendering and custom tags. It supports both a familiar
|
||||||
|
HTML syntax and a concise, indentation-based syntax.
|
||||||
|
---
|
||||||
|
|
||||||
|
ul.features
|
||||||
|
li for(feature in ['async', 'streaming', 'custom-tags', 'readable', 'modules'])
|
||||||
|
${feature}
|
||||||
|
|
||||||
|
ul if(notEmpty(data.colors))
|
||||||
|
li for(color in data.colors) - ${color}
|
||||||
|
div else
|
||||||
|
- No colors!
|
||||||
|
|
||||||
|
tabs
|
||||||
|
tabs:tab title="Tab 1"
|
||||||
|
- Body content for Tab 1
|
||||||
|
tabs:tab title="Tab 2"
|
||||||
|
- Body content for Tab 2
|
||||||
|
|
||||||
|
script type='text/javascript'
|
||||||
|
---
|
||||||
|
if (foo) {
|
||||||
|
alert('Marko is awesome!');
|
||||||
|
}
|
||||||
|
---
|
||||||
|
|
||||||
|
macro navLink(id, href, title)
|
||||||
|
li
|
||||||
|
a.nav-link class=(id === currentPage && 'active') href=href - ${title}
|
||||||
|
|
||||||
|
ul
|
||||||
|
navLink('home', '/', 'Home')
|
||||||
|
navLink('docs', '/docs', 'Docs')
|
||||||
|
navLink('blog', '/blog', 'Blog')
|
||||||
1
test/fixtures/render/autotest/syntax-concise/test.js
vendored
Normal file
1
test/fixtures/render/autotest/syntax-concise/test.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
exports.templateData = {};
|
||||||
5
test/fixtures/render/autotest/syntax-mixed/expected.html
vendored
Normal file
5
test/fixtures/render/autotest/syntax-mixed/expected.html
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<!DOCTYPE html> <html lang="en"><head><title>Marko Templating Engine</title></head><body><h1>Marko Templating Engine</h1><p>Marko is a <i>fast</i> and lightweight templating engine that compiles templates to CommonJS modules and supports streaming, async rendering and custom tags. It supports both a familiar HTML syntax and a concise, indentation-based syntax.</p><ul class="features"><li>async</li><li>streaming</li><li>custom-tags</li><li>readable</li><li>modules</li></ul><div>No colors!</div><div class="tabs"><ul><li>Tab 1</li><li>Tab 2</li></ul><div class="tab-content"><div class="tab">Body content for Tab 1</div><div class="tab">Body content for Tab 2</div></div></div><script type="text/javascript">
|
||||||
|
if (foo) {
|
||||||
|
alert('Marko is awesome!');
|
||||||
|
}
|
||||||
|
</script><ul><li><a class="nav-link active" href="/">Home</a></li><li><a class="nav-link" href="/docs">Docs</a></li><li><a class="nav-link" href="/blog">Blog</a></li></ul></body></html>
|
||||||
3
test/fixtures/render/autotest/syntax-mixed/marko.json
vendored
Normal file
3
test/fixtures/render/autotest/syntax-mixed/marko.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"<tabs>": "./tabs/marko-tag.json"
|
||||||
|
}
|
||||||
7
test/fixtures/render/autotest/syntax-mixed/tabs/marko-tag.json
vendored
Normal file
7
test/fixtures/render/autotest/syntax-mixed/tabs/marko-tag.json
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"renderer": "./renderer",
|
||||||
|
"@orientation": "string",
|
||||||
|
"@tabs <tab>[]": {
|
||||||
|
"@title": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
9
test/fixtures/render/autotest/syntax-mixed/tabs/renderer.js
vendored
Normal file
9
test/fixtures/render/autotest/syntax-mixed/tabs/renderer.js
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
var template =require('./template.marko');
|
||||||
|
|
||||||
|
exports.renderer = function(input, out) {
|
||||||
|
var tabs = input.tabs;
|
||||||
|
|
||||||
|
template.render({
|
||||||
|
tabs: tabs
|
||||||
|
}, out);
|
||||||
|
};
|
||||||
14
test/fixtures/render/autotest/syntax-mixed/tabs/template.marko
vendored
Normal file
14
test/fixtures/render/autotest/syntax-mixed/tabs/template.marko
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<var tabs=data.tabs/>
|
||||||
|
|
||||||
|
<div class="tabs">
|
||||||
|
<ul>
|
||||||
|
<li for(tab in tabs)>
|
||||||
|
${tab.title}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<div class="tab-content">
|
||||||
|
<div class="tab" for(tab in tabs)>
|
||||||
|
<invoke tab.renderBody(out) if(tab.renderBody)/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
52
test/fixtures/render/autotest/syntax-mixed/template.marko
vendored
Normal file
52
test/fixtures/render/autotest/syntax-mixed/template.marko
vendored
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
<var pageTitle="Marko Templating Engine"/>
|
||||||
|
<var currentPage='home'/>
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
html lang="en"
|
||||||
|
head
|
||||||
|
title - ${pageTitle}
|
||||||
|
body
|
||||||
|
h1 - ${pageTitle}
|
||||||
|
|
||||||
|
p
|
||||||
|
---
|
||||||
|
Marko is a <i>fast</i> and lightweight templating engine that
|
||||||
|
compiles templates to CommonJS modules and supports streaming,
|
||||||
|
async rendering and custom tags. It supports both a familiar
|
||||||
|
HTML syntax and a concise, indentation-based syntax.
|
||||||
|
---
|
||||||
|
|
||||||
|
ul.features
|
||||||
|
li for(feature in ['async', 'streaming', 'custom-tags', 'readable', 'modules'])
|
||||||
|
${feature}
|
||||||
|
|
||||||
|
ul if(notEmpty(data.colors))
|
||||||
|
li for(color in data.colors) - ${color}
|
||||||
|
div else
|
||||||
|
- No colors!
|
||||||
|
|
||||||
|
tabs
|
||||||
|
tabs:tab title="Tab 1"
|
||||||
|
- Body content for Tab 1
|
||||||
|
tabs:tab title="Tab 2"
|
||||||
|
- Body content for Tab 2
|
||||||
|
|
||||||
|
<script type='text/javascript'>
|
||||||
|
if (foo) {
|
||||||
|
alert('Marko is awesome!');
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<macro navLink(id, href, title)>
|
||||||
|
<li>
|
||||||
|
<a.nav-link class=(id === currentPage && 'active') href=href>
|
||||||
|
${title}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</macro>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<navLink('home', '/', 'Home')/>
|
||||||
|
<navLink('docs', '/docs', 'Docs')/>
|
||||||
|
<navLink('blog', '/blog', 'Blog')/>
|
||||||
|
</ul>
|
||||||
1
test/fixtures/render/autotest/syntax-mixed/test.js
vendored
Normal file
1
test/fixtures/render/autotest/syntax-mixed/test.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
exports.templateData = {};
|
||||||
5
test/fixtures/render/autotest/syntax-verbose/expected.html
vendored
Normal file
5
test/fixtures/render/autotest/syntax-verbose/expected.html
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<!DOCTYPE html> <html lang="en"><head><title>Marko Templating Engine</title></head><body><h1>Marko Templating Engine</h1><p>Marko is a <i>fast</i> and lightweight templating engine that compiles templates to CommonJS modules and supports streaming, async rendering and custom tags. It supports both a familiar HTML syntax and a concise, indentation-based syntax.</p><ul class="features"><li>async</li><li>streaming</li><li>custom-tags</li><li>readable</li><li>modules</li></ul><div>No colors!</div><div class="tabs"><ul><li>Tab 1</li><li>Tab 2</li></ul><div class="tab-content"><div class="tab">Body content for Tab 1</div><div class="tab">Body content for Tab 2</div></div></div><script type="text/javascript">
|
||||||
|
if (foo) {
|
||||||
|
alert('Marko is awesome!');
|
||||||
|
}
|
||||||
|
</script><ul><li><a class="nav-link active" href="/">Home</a></li><li><a class="nav-link" href="/docs">Docs</a></li><li><a class="nav-link" href="/blog">Blog</a></li></ul></body></html>
|
||||||
3
test/fixtures/render/autotest/syntax-verbose/marko.json
vendored
Normal file
3
test/fixtures/render/autotest/syntax-verbose/marko.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"<tabs>": "./tabs/marko-tag.json"
|
||||||
|
}
|
||||||
7
test/fixtures/render/autotest/syntax-verbose/tabs/marko-tag.json
vendored
Normal file
7
test/fixtures/render/autotest/syntax-verbose/tabs/marko-tag.json
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"renderer": "./renderer",
|
||||||
|
"@orientation": "string",
|
||||||
|
"@tabs <tab>[]": {
|
||||||
|
"@title": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
9
test/fixtures/render/autotest/syntax-verbose/tabs/renderer.js
vendored
Normal file
9
test/fixtures/render/autotest/syntax-verbose/tabs/renderer.js
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
var template =require('./template.marko');
|
||||||
|
|
||||||
|
exports.renderer = function(input, out) {
|
||||||
|
var tabs = input.tabs;
|
||||||
|
|
||||||
|
template.render({
|
||||||
|
tabs: tabs
|
||||||
|
}, out);
|
||||||
|
};
|
||||||
14
test/fixtures/render/autotest/syntax-verbose/tabs/template.marko
vendored
Normal file
14
test/fixtures/render/autotest/syntax-verbose/tabs/template.marko
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<var tabs=data.tabs/>
|
||||||
|
|
||||||
|
<div class="tabs">
|
||||||
|
<ul>
|
||||||
|
<li for(tab in tabs)>
|
||||||
|
${tab.title}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<div class="tab-content">
|
||||||
|
<div class="tab" for(tab in tabs)>
|
||||||
|
<invoke tab.renderBody(out) if(tab.renderBody)/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
61
test/fixtures/render/autotest/syntax-verbose/template.marko
vendored
Normal file
61
test/fixtures/render/autotest/syntax-verbose/template.marko
vendored
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
<var pageTitle="Marko Templating Engine"/>
|
||||||
|
<var currentPage='home'/>
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>${pageTitle}</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>${pageTitle}</h1>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Marko is a <i>fast</i> and lightweight templating engine that
|
||||||
|
compiles templates to CommonJS modules and supports streaming,
|
||||||
|
async rendering and custom tags. It supports both a familiar
|
||||||
|
HTML syntax and a concise, indentation-based syntax.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<ul.features>
|
||||||
|
<li for(feature in ['async', 'streaming', 'custom-tags', 'readable', 'modules'])>
|
||||||
|
${feature}
|
||||||
|
</li>
|
||||||
|
</>
|
||||||
|
|
||||||
|
<ul if(notEmpty(data.colors))>
|
||||||
|
<li for(color in data.colors)>${color}</li>
|
||||||
|
</ul>
|
||||||
|
<div else>
|
||||||
|
No colors!
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<tabs>
|
||||||
|
<tabs:tab title="Tab 1">
|
||||||
|
Body content for Tab 1
|
||||||
|
</tabs:tab>
|
||||||
|
<tabs:tab title="Tab 2">
|
||||||
|
Body content for Tab 2
|
||||||
|
</tabs:tab>
|
||||||
|
</tabs>
|
||||||
|
|
||||||
|
<script type='text/javascript'>
|
||||||
|
if (foo) {
|
||||||
|
alert('Marko is awesome!');
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<macro navLink(id, href, title)>
|
||||||
|
<li>
|
||||||
|
<a.nav-link class=(id === currentPage && 'active') href=href>
|
||||||
|
${title}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</macro>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<navLink('home', '/', 'Home')/>
|
||||||
|
<navLink('docs', '/docs', 'Docs')/>
|
||||||
|
<navLink('blog', '/blog', 'Blog')/>
|
||||||
|
</ul>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
1
test/fixtures/render/autotest/syntax-verbose/test.js
vendored
Normal file
1
test/fixtures/render/autotest/syntax-verbose/test.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
exports.templateData = {};
|
||||||
Loading…
x
Reference in New Issue
Block a user