Components
Create custom BoxLang components (tags) using BoxLang or Java
/**
* A custom greeting component
*
* @attr name The name to greet (required)
* @attr greeting The greeting prefix (default: "Hello")
*/
class {
property name="name" type="string";
property name="greeting" type="string" default="Hello";
/**
* This method is invoked when the component is used
* in template mode (with a body) or inline mode
*/
function invoke(
required any processor,
required struct context,
required struct attributes
) {
var message = "#attributes.greeting#, #attributes.name#!";
// Output the message
processor.getOutputBuffer().append( message );
// Process body content if any
if ( !isNull( processor.getBody() ) ) {
processor.processBody();
}
}
}Script-Style Usage
Naming Convention
Next Steps
Last updated
Was this helpful?
