Skip to content

Instantly share code, notes, and snippets.

@Seebiscuit
Last active January 23, 2022 13:53
Show Gist options
  • Save Seebiscuit/36de16cd457c5456f6ed7bf04d651090 to your computer and use it in GitHub Desktop.
Save Seebiscuit/36de16cd457c5456f6ed7bf04d651090 to your computer and use it in GitHub Desktop.
Replaceale Parts
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Dumber Gist</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
<base href="/">
</head>
<!--
Dumber gist uses dumber bundler, the default bundle file
is /dist/entry-bundle.js.
The starting module is pointed to aurelia-bootstrapper
(data-main attribute on script) for Aurelia,
The aurelia bootstrapper then loads up user module "main"
(aurelia-app attribute on <body>) which is your src/main.js.
-->
<body aurelia-app="main">
<script src="/dist/entry-bundle.js" data-main="aurelia-bootstrapper"></script>
</body>
</html>
{
"dependencies": {
"aurelia-bootstrapper": "latest"
}
}
<template>
<require from="./table-component.html"></require>
<require from="./my-component.html"></require>
<h4>Custom template with dynamic part</h4>
<table-component columns.bind="appColumns">
<template replace-part="${column}">
<div>From app</div>
<strong>${column}</strong>
</template>
</table-component>
<h4>Custom template with default and custom</h4>
<table-component columns.bind="appColumns">
<template replace-part="part1">
<div>From app</div>
<strong>${column}</strong>
</template>
</table-component>
</template>
<template>
<require from="./awesome-table.html"></require>
<require from="./table-component.html"></require>
<require from="./my-component.html"></require>
<style>
.sans-serif {
font-family: sans-serif;
}
</style>
<!--
<awesome-table columns.bind="appColumns">
</awesome-table>
-->
<awesome-table columns.bind="appColumns">
<!-- <template replace-part="outer-${columnPart}"> -->
<th data-app-part="true">
<template
replace-part="inner-columns"
>
<my-component
if.bind="columnPart === 'part1'"
class="sans-serif"
>
App Value1 <span style="font-weight:normal;">${columnPart}</span>
</my-component>
<my-component
else
>
App Value2 <span style="font-weight:normal;">${columnPart}</span>
</my-component>
</template>
</th>
<!-- </template> -->
<template replace-part="inner">
<em>
Column Inner ${columnPart}
</em>
</template>
<template replace-part="content">
<em>
Content ${columns}
</em>
<br>
<my-component>
<template replace-part="content">
Component Content
</template>
</my-component>
</template>
</awesome-table>
<!--
<th repeat.for="columnPart of columns" rreplace-part="header">${columnPart.name}</th>
-->
<hr>
<hr>
<template replace-part="content">
<div>My component</div>
<strong>${columns}</strong>
</template>
<h4>Default template</h4>
<table-component columns.bind="appColumns"></table-component>
<hr>
<h4>Custom template with dynamic part</h4>
<table-component columns.bind="appColumns">
<template replace-part="${column}">
<div>From app</div>
<strong>${column}</strong>
</template>
</table-component>
<h4>Custom template with default and custom part</h4>
<table-component columns.bind="appColumns">
<template replace-part="part1">
<div>From app</div>
<strong>${column}</strong>
</template>
</table-component>
</template>
export class App {
appColumns = ['part1', 'part2']
}
<template bindable="columns">
<h5>Table</h5>
<table>
<thead>
<tr>
<th repeat.for="columnPart of columns" replaceable part="outer-${columnPart}">
|
<template replaceable part="inner-columns">
Default Value <span style="font-weight:normal;">${columnPart}</span>
</template>
</th>
</tr>
</thead>
</table>
<h5>Element</h5>
<template replaceable part="content">
Default Value
</template>
</template>
export function configure(aurelia) {
aurelia.use
.standardConfiguration()
.developmentLogging('info');
aurelia.start().then(() => aurelia.setRoot());
}
<template>
<slot>
Default Value
</slot>
</template>
<template bindable="columns">
<table>
<thead>
<th repeat.for="column of columns">
<template replaceable part="columns">
Default Value <span style="font-weight:normal;">${column}</span>
</template>
</th>
</thead>
</table>
</template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment