Last active
February 21, 2018 16:18
-
-
Save djedi/d3c8b68f5cf4a015a5f0fa35e7d94de3 to your computer and use it in GitHub Desktop.
code sample component
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="./my-code-sample"></require> | |
<require from="./my-button.html"></require> | |
<my-code-sample> | |
<br><hr><hr> | |
</my-code-sample> | |
<my-code-sample> | |
<table border="1"> | |
<thead> | |
<tr> | |
<td>Head 1</td> | |
</tr> | |
</thead> | |
<tbody> | |
<tr> | |
<td>Cell 1</td> | |
</tr> | |
</tbody> | |
</table> | |
</my-code-sample> | |
<my-code-sample> | |
<my-button></my-button> | |
</my-code-sample> | |
</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
<!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> |
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> | |
<span style="display: none"><slot></slot></span> | |
<style> | |
pre { | |
background-color: #eee; | |
border: 1px solid #999; | |
padding: 3px 9px; | |
} | |
</style> | |
<div> | |
<div> | |
<pre><code class="language-markup" au-syntax textcontent.bind="code"></code></pre> | |
</div> | |
<template replaceable part="rendered"></template> | |
</div> | |
<br><br> | |
</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
import {processContent, child} from 'aurelia-framework'; | |
@processContent((compiler, resources, node) => { | |
const originalContent = node.innerHTML; | |
const stringified = JSON.stringify(originalContent); | |
node.innerHTML = `<code-sample data.bind='${stringified}'></code-sample>`; | |
node.innerHTML += `<template replace-part="rendered">${originalContent}</template>`; | |
return true; | |
}) | |
export class MyCodeSample { | |
@child('code-sample') codeSample; | |
attached() { | |
this.code = this.codeSample.data.trim(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment