Skip to content

Instantly share code, notes, and snippets.

@AshleyGrant
Last active February 19, 2018 11:52
Show Gist options
  • Save AshleyGrant/878bf59ffa05a09c6d996b6c41b9674e to your computer and use it in GitHub Desktop.
Save AshleyGrant/878bf59ffa05a09c6d996b6c41b9674e to your computer and use it in GitHub Desktop.
au wizard element with page element
<template>
<require from='./wizard'></require>
<wizard>
<page>
<p>
Page 1
</p>
</page>
<page>
${names[2]}
</page>
</wizard>
</template>
export class App {
names = ['Jane', 'John']
}
<!doctype html>
<html>
<head>
<title>Aurelia</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css">
<style>
body {
padding: 20px;
}
.form-component {
display: block;
margin-bottom: 20px;
}
</style>
</head>
<body aurelia-app>
<h1>Loading...</h1>
<script src="https://jdanyow.github.io/rjs-bundle/node_modules/requirejs/require.js"></script>
<script src="https://jdanyow.github.io/rjs-bundle/config.js"></script>
<script src="https://jdanyow.github.io/rjs-bundle/bundles/aurelia.js"></script>
<script src="https://jdanyow.github.io/rjs-bundle/bundles/babel.js"></script>
<script>
require(['aurelia-bootstrapper']);
</script>
</body>
</html>
<template>
<slot></slot>
</template>
export class Page {
}
<template>
<slot></slot>
<div>
<button disabled.bind="currentPage === 1" click.trigger="currentPage = currentPage - 1">&lt;&lt;</button>
<button disabled.bind="currentPage === pages.length - 1" click.trigger="currentPage = currentPage + 1">&gt;&gt;</button>
</div>
</template>
import { processContent, children} from 'aurelia-framework';
@processContent(parsePages)
export class Wizard {
@children('page') pages;
currentPage = 1;
attached() {
console.log('pages', this.pages);
}
}
function parsePages(compiler, resources, node, instruction) {
const pages = node.querySelectorAll('page');
for( let i = 0, numberOfPages = pages.length; i < numberOfPages; i++ ) {
const page = pages[i];
page.setAttribute('if.bind', `currentPage === ${i+1}`)
}
console.log('node', node)
console.log('node.innerHTML', node.innerHTML)
// debugger;
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment