2.C. Reference Format Types - CradlePHP/Cradle GitHub Wiki
- 2.C.1. Lower Case
- 2.C.2. Upper Case
- 2.C.3. Capitalize
- 2.C.4. Character Length
- 2.C.5. Word Length
- 2.C.6. Date Format
- 2.C.7. Relative Format
- 2.C.8. Raw HTML
- 2.C.9. Strip HTML
- 2.C.10. Markdown
- 2.C.11. Link
- 2.C.12. Image
- 2.C.13. Email
- 2.C.14. Phone
- 2.C.15. Formula
- 2.C.16. Comma Separated
- 2.C.17. Price Format
- 2.C.18. Yes/No
- 2.C.19. Custom Format
- 2.C.20. Dont Show
- 2.C.21. No Filter
Output formats are used to display the correct representation of a value. If you can't find the format you need, you can create a custom format with Custom Format. This accepts all the Handlebars Helpers.
Transforms the value to lower case.
Foo Bar -> foo bar
Transforms the value to upper case.
Foo Bar -> FOO BAR
Capitalizes the value.
foo bar -> Foo Bar
Limits the value to the specified amount of characters
foo bar -> foo b
Limits the value to the specified amount of words
foo bar -> foo
Formats the value to a specified date format
2018-01-01 -> January 01, 2018
Formats the value to a specified relative date format
2018-01-01 -> 3 months ago
2016-01-01 -> January 01, 2016
If the value contains HTML, by default we escape these tags. This format will allow the use of HTML as an output
Strips HTML from the value
<p>something <b>strong</b> happened</p> -> something <b>strong</b> happened
If the value contains Markdown, this will convert it to HTML.
Converts value to a link tag. The first parameter is the value of the href attribute of the link tag. The second parameter is for the inner text of the link tag.
<a href="/some/link">Foobar</a>
Both parameters can optionally accept Handlebars variables. Handlebars variables are relative to the model that is using this format.
/some/path/{{article_title}}
Converts a value to an image tag.
<img src="/some/path/{{value}}" width="100" height="200" />
Converts value to an email link.
Given [email protected]
and Foobar
<a href="mailto:[email protected]">Foobar</a>
Converts value to an email link.
<a href="tel:555-2424">Foobar</a>
Compiles the given Handlebars template and evaluates the final formula.
Given
-
product
hasprice
andtax
-
price
is 100 -
tax
is 20
{{product_price}} + {{product_tax}} -> 100 + 20 -> 120
Joins an array into a comma separated string
Adds commas and 2 decimal places to the number value
Transforms the value to either Yes or No.
1 -> Yes
0 -> No
Compiles the given Handlebars template.
Given
-
product
hasname
andprice
-
name
is iphone -
price
is 1000
{{product_name}} - ${{product_price}} -> iphone - $1000
Hides the value
Performs no formatting on the value