Download the PHP package alexoliverwd/brace without Composer
On this page you can find all versions of the php package alexoliverwd/brace. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download alexoliverwd/brace
More information about alexoliverwd/brace
Files in alexoliverwd/brace
Package brace
Short Description A simple template language written in PHP
License MIT
Informations about the package brace
Brace
brace is a simple template language written in PHP. Brace uses a handlebar style syntax.
- Requirements
- Installation
- Via composer
- Or Including the brace class
- Usage
- Returning processes templates as a string
- Compiling to an external file
- Instance variables
- Template Reference
- Variables
- In-line "or" operator
- Multiple In-line "or" operators
- Return variable values by an array index value
- Iterators
- In-line Iterators
- Nth children
- Row keys
- Iteration data variables
- Loops
- Increasing
- Decreasing
- Loop data variables
- Conditional Statements
- Condition Blocks
- Else If Statements
- In-line conditions
- Conditions
- Including Templates
- Shortcodes
- PHP Implementation Example
- Content Template
- Array Counting
- Display Count:
- Check Count
- Comment Blocks
- In-line Comment Block
- Multiple Line Comment Block
- Clearing cached process string
- Running Tests
- Variables
Requirements
Brace requires PHP version 8.1 or later.
Installation
Via composer
Or Including the brace class
Usage
Returning processes templates as a string
Compiling to an external file
Instance variables
Variable | Description | Default value |
---|---|---|
Keep or remove comment blocks from templates | [Boolean] | |
Set directory to load template files from | [String] Current working directory | |
Template file extension | [String] |
Template Reference
Variables
In-line "or" operator
Multiple In-line "or" operators
Return variable values by an array index value
Result:
Iterators
In-line Iterators
Or
Nth children
Row keys
Or
Iteration data variables
Variables that are added to each iteration.
ID | Description | Type |
---|---|---|
_ITERATION | Iteration value (is_first_item, is_last_item, 2, 3 etc) | String |
_ROW_ID | Record/Row ID (1,2,3, etc) | Integer |
_KEY | Record/Row key | Mixed |
GLOBAL | An array of external record data that is accessible to all rows | Array |
Loops
Increasing
Decreasing
Loop data variables
Variables that are added to each iteration.
ID | Description | Type |
---|---|---|
_KEY | Row key | Integer |
Conditional Statements
Condition Blocks
Else If Statements
In-line conditions
Escaping quotations
Conditions
Condition | Description |
---|---|
== | Is equal to (Loose equality comparison) |
=== | Is equal to (Strict equality comparison) |
>= | More than or equal to |
<= | Less than or equal to |
> | More than |
< | Less than |
!= | Is not equal (Loose non equality comparison) |
!! | Is not |
!== | Is not equal (Same as !! operator, strict non equality comparison |
EXISTS | Exists |
!EXISTS | Does not exist |
Including Templates
Shortcodes
PHP Implementation Example
Content Template
Array Counting
Ability to check and display array item counts
Display Count:
Check Count
Comment Blocks
In-line Comment Block
Multiple Line Comment Block
Clearing cached process string
The --clear-- method is useful when needing to processes multiple templates with differing data using the same brace instance.
By default brace does not clear a processed string at the end of executing a template/string parse.
Running Tests
Running PHPStan and PHPUnit tests can be achieved with the following commands
Or by running via composer