Learn how to extend Aurelia's binding language with custom binding commands, attribute patterns, and template syntax extensions.
Aurelia's binding system is powerful and extensible by design. This advanced scenario teaches you how to create custom binding commands (like .bind, .trigger), define attribute patterns, and extend the template compiler to add your own domain-specific syntax to Aurelia templates.
Why This Is an Advanced Scenario
Extending the binding engine requires deep understanding of:
Template compilation - How Aurelia parses and compiles templates
Binding instructions - Low-level directives that drive the rendering pipeline
Attribute patterns - How Aurelia recognizes and categorizes attributes
Expression parsing - AST manipulation and custom expression types
Rendering pipeline - How instructions become live bindings
Framework internals - Runtime architecture and lifecycle hooks
Use cases for binding engine extensions:
Custom DSLs - Domain-specific template languages
Framework integration - Adapt other framework syntaxes
Performance optimization - Specialized binding modes for specific use cases
Developer experience - Shorthand syntax for common patterns
Legacy migration - Support old syntax during gradual upgrades
Complete Guides
Aurelia provides several extension points for the binding system:
1. Custom Binding Commands
Create new binding commands like .my-bind or .special-trigger:
<!-- Use :value instead of value.bind -->
<input :value="username" type="text">
// Create .once binding that only binds on first render
@bindingCommand('once')
export class OnceBindingCommand {
build(info, parser) {
const expr = parser.parse(info.attr.rawValue, 'IsProperty');
return new PropertyBindingInstruction(expr, info.attr.target, 'oneTime');
}
}