-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for binding row data to grid types, and for row_attr option
- Loading branch information
Sander Marechal
committed
Mar 28, 2024
1 parent
c9913c5
commit 8922d92
Showing
20 changed files
with
219 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Grid type | ||
============ | ||
|
||
The base grid type | ||
|
||
## Class | ||
|
||
`Prezent\Grid\Extension\Core\Type\GridType` | ||
|
||
## Options | ||
|
||
### `attr` | ||
|
||
The HTML attributes for the element that is used to render on the table. | ||
|
||
### `row_attr` | ||
|
||
The HTML attributes for the element that is used to render on each table row. For every attribute, values between braces | ||
are interpreted as a property path and will be expanded when the attribute is rendered. E.g. an attribute value | ||
of `{name}` will be rendered as `foo` if the `name` property of the row is `'foo'`. | ||
|
||
For every attribute you can also supply a callback that returns a value. The callback is passed the row as only parameter. | ||
|
||
## Parent type | ||
|
||
None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Prezent\Grid\Twig\Node; | ||
|
||
use Prezent\Grid\Twig\GridRenderer; | ||
use Twig\Compiler; | ||
use Twig\Node\Expression\FunctionExpression; | ||
|
||
/** | ||
* Compile a grid block | ||
* | ||
* @see FunctionExpression | ||
* @author Sander Marechal | ||
*/ | ||
class RenderGridBlockNode extends FunctionExpression | ||
{ | ||
public function compile(Compiler $compiler): void | ||
{ | ||
$compiler->addDebugInfo($this); | ||
$arguments = iterator_to_array($this->getNode('arguments')); | ||
|
||
$compiler | ||
->write('$this->env->getRuntime(\''. GridRenderer::class . '\')->renderBlock(') | ||
->raw('\''.$this->getAttribute('name').'\''); | ||
|
||
foreach ($arguments as $argument) { | ||
$compiler->raw(', '); | ||
$compiler->subcompile($argument); | ||
} | ||
|
||
$compiler->raw(')'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.