Skip to content

Instantly share code, notes, and snippets.

@mneuhaus
Created October 9, 2015 10:24
Show Gist options
  • Save mneuhaus/26b54e0698d0f8c644a6 to your computer and use it in GitHub Desktop.
Save mneuhaus/26b54e0698d0f8c644a6 to your computer and use it in GitHub Desktop.
<?php
namespace Famelo\Soup\ViewHelpers;
/*
* This file belongs to the package "TYPO3 Fluid".
* See LICENSE.txt that was shipped with this package.
*/
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
/**
*
* @api
*/
class BlockViewHelper extends AbstractViewHelper {
/**
* @var boolean
*/
protected $escapeOutput = FALSE;
/**
* @return void
*/
public function initializeArguments() {
parent::initializeArguments();
$this->registerArgument('partial', 'string', 'Partial to render, with or without section');
$this->registerArgument('arguments', 'array', 'Array of variables to be transferred. Use {_all} for all variables', FALSE, array());
}
/**
* Renders the content.
*
* @return string
* @api
*/
public function render() {
$partial = $this->arguments['partial'];
$arguments = (array) $this->arguments['arguments'];
$arguments['content'] = $this->renderChildren();
return $this->viewHelperVariableContainer->getView()->renderPartial($partial, NULL, $arguments);
}
/**
* @param array $arguments
* @return void
*/
public function handleAdditionalArguments(array $arguments) {
$this->arguments['arguments'] = array_replace(
$this->arguments['arguments'],
$arguments
);
}
}
<div class="card card-expandable depth-2">
<div class="card-header">
{header}
</div>
<div class="card-body">
{content->f:format.raw()}
</div>
</div>
<s:block partial="Card" header="Some Header">
lorem ipsum dolor set amet
</s:block>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment