diff --git a/Decoda/Decoda.php b/Decoda/Decoda.php index f3933d9..24d4746 100644 --- a/Decoda/Decoda.php +++ b/Decoda/Decoda.php @@ -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; + } } diff --git a/Tests/FunctionalTestBundle/Resources/config/config.yml b/Tests/FunctionalTestBundle/Resources/config/config.yml index 09839b5..9f2d55d 100644 --- a/Tests/FunctionalTestBundle/Resources/config/config.yml +++ b/Tests/FunctionalTestBundle/Resources/config/config.yml @@ -63,6 +63,8 @@ fm_bbcode: hooks: [ bar ] emoticon_filter: hooks: [ emoticon ] + list_filter: + filters: [ list ] framework: form: ~ diff --git a/Tests/FunctionalTestBundle/Resources/views/filters/list.html.twig b/Tests/FunctionalTestBundle/Resources/views/filters/list.html.twig new file mode 100644 index 0000000..7f38b6e --- /dev/null +++ b/Tests/FunctionalTestBundle/Resources/views/filters/list.html.twig @@ -0,0 +1 @@ +{{value|bbcode_filter('list_filter')}} \ No newline at end of file diff --git a/Tests/Templating/BbcodeExtensionTest.php b/Tests/Templating/BbcodeExtensionTest.php index 9225111..117b15d 100644 --- a/Tests/Templating/BbcodeExtensionTest.php +++ b/Tests/Templating/BbcodeExtensionTest.php @@ -2,6 +2,8 @@ namespace FM\BbcodeBundle\Tests\Templating; +use Decoda\Filter\ListFilter; + use FM\BbcodeBundle\Tests\TwigBasedTestCase; class BbcodeExtensionTest extends TwigBasedTestCase @@ -209,4 +211,29 @@ public function dataEmoticonHook() array(':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]', ''), + array('[list][*]Item 1[olist][*]Item 1[*]Item 2[/olist][*]Item 2[/list]', ''), + ); + } }