Last active
December 7, 2016 05:03
-
-
Save Vheissu/c7f914adec6ead45d01ba94ecdd8b5d5 to your computer and use it in GitHub Desktop.
Aurelia code snippet custom element demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<require from="./code-snippet"></require> | |
<code-snippet model.bind="{name: 'Rob', likes: ['apples', 'oranges', 'bananas', 'pineapples']}"> | |
<h1>Hello, my name is: ${name}</h1> | |
<h2>My favourite fruits are:</h2> | |
<ul> | |
<li repeat.for="fruit of likes">${fruit}</li> | |
</ul> | |
</code-snippet> | |
</template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class App { | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Code Snippet Custom Element | |
* | |
* @author Dwayne Charrington <[email protected]> | |
* @copyright Dwayne Charrington 2016 | |
* | |
* https://discoveraurelia.com | |
* | |
*/ | |
import {bindable, inject, noView, processContent, TemplatingEngine} from 'aurelia-framework'; | |
@processContent(false) | |
@noView | |
@inject(Element, TemplatingEngine) | |
export class CodeSnippetCustomElement { | |
@bindable model; | |
constructor(element, templatingEngine) { | |
this.element = element; | |
this.templatingEngine = templatingEngine; | |
} | |
attached() { | |
this.enhance(); | |
} | |
enhance() { | |
for (let i = 0; i < this.element.children.length; i++) { | |
this.templatingEngine.enhance({ | |
bindingContext: this.model, | |
element: this.element.children.item(i) | |
}); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<title>Aurelia</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
</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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment