Skip to content

Instantly share code, notes, and snippets.

@opcodewriter
Last active March 9, 2016 11:04
Show Gist options
  • Save opcodewriter/b50643a0f6ad2d99273d to your computer and use it in GitHub Desktop.
Save opcodewriter/b50643a0f6ad2d99273d to your computer and use it in GitHub Desktop.
Aurelia ContentControl
<template>
<require from="./contentControl.html"></require>
<require from="./myCustomComponent"></require>
<content-control content-template='myCustomTemplate.html' content='this is content rendered with myCustomTemplate'></content-control>
<!-- set a template of a another component-->
<!--<content-control content-template='myCustomComponent' content='this doesnt matter'></content-control> -->
<!-- set actual content with an instance of another component-->
<content-control>
<my-custom-component text="Hello"></my-custom-component>
</content-control>
</template>
export class App {
}
<template bindable='content,contentTemplate'>
<compose if.bind='contentTemplate' view='${contentTemplate}' containerless></compose>
<!-- how to make this containerless too? -->
<div if.bind='!contentTemplate'>
${content}
</div>
<content></content>
</template>
import {bindable} from 'aurelia-framework';
export class ContentControl
{
@bindable content;
@bindable contentTemplate;
}
<!doctype html>
<html>
<head>
<title>Aurelia</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="styles.css">
</head>
<body aurelia-app>
<h1>Loading...</h1>
<script src="https://cdn.rawgit.com/jdanyow/aurelia-bundle/master/jspm_packages/system.js"></script>
<script src="https://cdn.rawgit.com/jdanyow/aurelia-bundle/master/config.js"></script>
<script>
System.import('aurelia-bootstrapper');
</script>
</body>
</html>
<template>
<button>${text}</button>
</template>
import {bindable} from 'aurelia-framework'
export class MyCustomComponent
{
@bindable text;
}
<template>
<div style="background:lightblue">${content}</div>
</template>
a {
display: block;
}
a:link {
color: black;
text-decoration: none;
}
.collection-item
{
background: lightgray;
}
/* since you set background property on .collection-item, this style must come after .collection-item otherwise it's not applied */
.active {
background: blue;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment