Presenter Output
This section will show you how to use the decorated value provided by the \Anomaly\TextareaFieldType\TextareaFieldTypePresenter
class.
TextareaFieldTypePresenter::yaml()
The yaml
method parses the value as YAML.
Returns: mixed
Example
$decorated->example->yaml()['some_key'];
Twig
{{ decorated.example.yaml().some_key }}
TextareaFieldTypePresenter::lines()
The lines
method returns an array of lines from within the value.
Returns: array
Arguments
Key | Required | Type | Default | Description |
---|---|---|---|---|
$limit |
false |
integer |
9999 |
The maximum length of the value allowed into the explode function. |
Example
echo count($decorated->example->lines());
Twig
<ul>
<li>
{% for line in decorated.example.lines() %}
{{ line }}
{% endfor %}
</li>
</ul>
TextareaFieldTypePresenter::line()
The line
method returns a specific line value.
Returns: string
Arguments
Key | Required | Type | Default | Description |
---|---|---|---|---|
$line |
true |
integer |
1 |
The line you would like to return. |
Example
$decorated->example->line(1); // Street address
$decorated->example->line(2); // City, State, ZIP
Twig
{{ decorated.example.line(1) }} // Street address
{{ decorated.example.line(2) }} // City, State, ZIP
TextareaFieldTypePresenter::limit()
The limit
method returns a truncated and capped string if longer than the specified limit.
Returns: string
Arguments
Key | Required | Type | Default | Description |
---|---|---|---|---|
$limit |
true |
integer |
100 |
The maximum length allowed before truncating and finishing with the string end. |
$end |
true |
string |
... |
The ending that will be appended to the string if truncated. |
Example
$decorated->example->limit(); // 100 characters...
Twig
{{ decorated.example.limit() }} // 100 characters...