Skip to content

Instantly share code, notes, and snippets.

@opcodewriter
Last active March 17, 2016 06:53
Show Gist options
  • Save opcodewriter/984cd906bbc27eedc52a to your computer and use it in GitHub Desktop.
Save opcodewriter/984cd906bbc27eedc52a to your computer and use it in GitHub Desktop.
Aurelia Custom H Tag
<template>
<require from='dynamic-header'></require>
<dynamic-header containerless></dynamic-header>
</template>
export class App {
}
<template>
<require from="outerHtmlAttribute"></require>
<!--<span innerhtml.bind="innerHtml()"> </span>-->
<h1 outer-html.bind="level">HELLO</h1>
</template>
import {bindable, inject} from 'aurelia-framework';
@inject(Element)
export class DynamicHeader {
@bindable level = "1";
/*innerHtml()
{
return `<h${this.level}>Header 1</h${this.level}>`;
}*/
constructor(element)
{
this.element = element;
}
}
<!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/v1.0.3/jspm_packages/system.js"></script>
<script src="https://cdn.rawgit.com/jdanyow/aurelia-bundle/v1.0.3/config.js"></script>
<script>
System.import('aurelia-bootstrapper');
</script>
</body>
</html>
import {inject, customAttribute} from 'aurelia-framework';
@customAttribute('outer-html')
@inject(Element)
export class OuterHtmlAttribute {
constructor(element) {
this.element = element;
}
valueChanged(newValue, oldValue) {
this.element.outerHTML = `<h${newValue}>${this.element.innerHTML}</h${newValue}>`;
}
}
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