Components
BoxLang components are reusable blocks of code that extend the language's capabilities without modifying the parser.
<bx:output>
<h1>Hello, #attributes.yourname ?: "None Passed"#!</h1>
</bx:output>// In a BoxLang script
bx:_greeting yourname="World";<bx:_greeting yourname="World"><h1>Hello, World!</h1>📋 Table of Contents
Why Components Matter
Basic Principles
Component Syntax
Script Context:
Template Context:
Component Execution Flow
Core and Module Components
Core Components
Module Components
Creating Custom Components
Basic Custom Component Structure
Template-based Component
Script-based Component
Component Input: The attributes Scope
attributes ScopeTemplate-based Component with Attributes
Script-based Component with Attributes
Component Content: The thisComponent Scope
thisComponent ScopeTemplate-based Component with thisComponent
thisComponentScript-based Component with thisComponent
thisComponentComplex Component with Start/End Logic
Template-based Version
Script-based Version
Custom Component Discovery
Discovery Configuration
Global Configuration (boxlang.json):
boxlang.json):Application Configuration (Application.bx):
Application.bx):File Extensions Searched
Calling Custom Components
Method 1: Using bx:component
bx:componentMethod 2: Convention-Based Calling
Component Scopes Deep Dive
The attributes Scope
attributes ScopeThe variables Scope
variables ScopeThe caller Scope
caller ScopeThe thisComponent Scope
thisComponent ScopeAssociating Subtag Data with Base Tags
How Component Association Works
Basic Association Syntax
Simple Example: Menu with Menu Items
Advanced Example: Form with Form Fields
Key Points About bx:associate
bx:associate1. Data Collection Names
2. Automatic Array Creation
3. Attribute Inheritance
4. Execution Timing
5. Nested Associations
Advanced Pattern: Tab Container
Advanced Component Patterns
Component Composition
Conditional Component Loading
Best Practices
1. Always Use bx:param for Attribute Validation
bx:param for Attribute Validation2. Use Descriptive Component Names
3. Document Your Components
4. Minimize Use of caller Scope
caller ScopeMigration from CFML Custom Tags
CFML Custom Tags
BoxLang Components
Last updated
Was this helpful?
