Global Helpers
excerpt()
Signature
Section titled “Signature”excerpt() — returns string
Available in: controller, model, mapper, migrator, migration, tabledefinition
Category: String Functions
Description
Section titled “Description”Extracts an excerpt from text that matches the first instance of a given phrase.
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
text | string | yes | — | The text to extract an excerpt from. |
phrase | string | yes | — | The phrase to extract. |
radius | numeric | no | 100 | Number of characters to extract surrounding the phrase. |
excerptString | string | no | ... | String to replace first and / or last characters with. |
Examples
Section titled “Examples”// 1. Extract text around a matching phrase with a custom radius
result = excerpt(text="CFWheels is a Rails-like MVC framework for Adobe ColdFusion and Lucee", phrase="framework", radius=5);
// result -> "...MVC framework for Ad..."
// 2. Use the default radius of 100 characters
result = excerpt(text="CFWheels is a powerful MVC framework built for ColdFusion developers who want to move fast.", phrase="powerful");
// result -> "CFWheels is a powerful MVC framework built for ColdFusion developers who want to move fast."
// 3. Customize the excerpt string used to indicate truncated text
result = excerpt(text="The quick brown fox jumps over the lazy dog", phrase="fox", radius=5, excerptString=" [...]");
// result -> " [...]brown fox jumps [...]"