Skip to content

Commit

Permalink
Merge pull request #103 from alquerci/issue-71
Browse files Browse the repository at this point in the history
Fixed list with star
  • Loading branch information
helios-ag committed Mar 4, 2015
2 parents 4f1aba0 + a54884d commit 79fa6f2
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Decoda/Decoda.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,4 +273,20 @@ public function removeHook($ids)
{
return parent::removeHook(array_map('strtolower', (array) $ids));
}

/**
* {@inheritdoc}
*/
protected function _extractChunks($string)
{
if (isset($this->_filters['list'])) {
$this->_filters['List'] = true;
}

$nodes = parent::_extractChunks($string);

unset($this->_filters['List']);

return $nodes;
}
}
2 changes: 2 additions & 0 deletions Tests/FunctionalTestBundle/Resources/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ fm_bbcode:
hooks: [ bar ]
emoticon_filter:
hooks: [ emoticon ]
list_filter:
filters: [ list ]

framework:
form: ~
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{value|bbcode_filter('list_filter')}}
27 changes: 27 additions & 0 deletions Tests/Templating/BbcodeExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace FM\BbcodeBundle\Tests\Templating;

use Decoda\Filter\ListFilter;

use FM\BbcodeBundle\Tests\TwigBasedTestCase;

class BbcodeExtensionTest extends TwigBasedTestCase
Expand Down Expand Up @@ -209,4 +211,29 @@ public function dataEmoticonHook()
array(':my_emoticon:', '<img src="/emoticons//my_emoticon.png" alt="" title="my_emoticon" />'),
);
}


/**
* @dataProvider dataListFilterWithStar
*/
public function testListFilterWithStar($value, $expected)
{
$filter = new ListFilter();
if (!array_key_exists('*', $filter->getTags())) {
$this->markTestSkipped('Required Decoda version >= 6.2.0');
}

$this->assertSame($expected,
$this->getTwig()->render('FunctionalTestBundle:filters:list.html.twig', array(
'value' => $value,
)));
}

public function dataListFilterWithStar()
{
return array(
array('[list][*]Item 1[*]Item 2[/list]', '<ul class="decoda-list"><li>Item 1</li><li>Item 2</li></ul>'),
array('[list][*]Item 1[olist][*]Item 1[*]Item 2[/olist][*]Item 2[/list]', '<ul class="decoda-list"><li>Item 1</li><li>Item 1</li><li>Item 2</li><li>Item 2</li></ul>'),
);
}
}

0 comments on commit 79fa6f2

Please sign in to comment.