Skip to content
This repository has been archived by the owner on Aug 10, 2022. It is now read-only.

Commit

Permalink
Merge pull request #49 from archdevil666pl/v1.1
Browse files Browse the repository at this point in the history
Decorated form elements in default CRUD templates
  • Loading branch information
arius86 committed Sep 23, 2015
2 parents d858d3b + 241fd6d commit 87f79a0
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Mvc/Controller/Crud/views/edit.volt
Expand Up @@ -30,7 +30,7 @@
{% endfor %}
</span>
{% endif %}
{{ element }}
{% if methodExists(element, 'renderDecorated') %}{{ element.renderDecorated() }}{% else %}{{ element }}{% endif %}
</div>
{% endfor %}

Expand Down
2 changes: 1 addition & 1 deletion src/Mvc/Controller/Crud/views/new.volt
Expand Up @@ -30,7 +30,7 @@
{% endfor %}
</span>
{% endif %}
{{ element }}
{% if methodExists(element, 'renderDecorated') %}{{ element.renderDecorated() }}{% else %}{{ element }}{% endif %}
</div>
{% endfor %}

Expand Down
33 changes: 33 additions & 0 deletions src/Mvc/View/Engine/Volt/Helper/MethodExists.php
@@ -0,0 +1,33 @@
<?php
/**
* This file is part of Vegas package
*
* @author Radosław Fąfara <radek@amsterdamstandard.com>
* @copyright Amsterdam Standard Sp. Z o.o.
* @homepage http://vegas-cmf.github.io
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Vegas\Mvc\View\Engine\Volt\Helper;

use Vegas\Mvc\View\Engine\Volt\VoltHelperAbstract;

/**
* Class MethodExists
* @package Vegas\Mvc\View\Engine\Volt\Helper
*/
class MethodExists extends VoltHelperAbstract
{

/**
* Proxies to method_exists() PHP function
*
* @return string
*/
public function getHelper()
{
return 'method_exists';
}
}
2 changes: 2 additions & 0 deletions tests/Mvc/View/Engine/VoltTest.php
Expand Up @@ -29,6 +29,8 @@ public function testHelpers()

$compiler = $volt->getCompiler();

$this->assertEquals('<?php echo method_exists($object, \'method\'); ?>', $compiler->compileString('{{ methodExists(object, "method") }}'));

$this->assertEquals('<?php echo (new \Vegas\Tag\ShortenText())->prepare(\'foo\',100, "..."); ?>', $compiler->compileString('{{ shortenText("foo") }}'));
$this->assertEquals('<?php echo (new \Vegas\Tag\ShortenText())->prepare(\'foo\',50, \'bar\'); ?>', $compiler->compileString('{{ shortenText("foo", 50, "bar") }}'));

Expand Down

0 comments on commit 87f79a0

Please sign in to comment.