On Tue, 11 Jan 2011 08:45:32 -0500, Tom Boutell <[email protected]> wrote: > Over on symfony-users I've sent out a mini-HOWTO on implementing Twig > filters in Symfony bundles. There is one in SillyCMS now: > > https://github.com/boutell/SillyCMS > > It implements a really basic Wiki syntax, just to demonstrate the > technique. > > You can certainly do it using namespaced functions, but I wonder why > Twig doesn't allow callables in general? > > Since Twig accepts only a function name as a string, methods and > closures are not an option. > > I'd like to write this: > > public function getFilters() > { > return array( > 'wiki_text' => new Twig_Filter_Function(function($text) { > CODE GOES HERE }, array('is_safe' => array('html'), 'pre_escape' => > 'html')) > ); > } > > Any special reason this should not be supported? > > Thanks! > > -- > Tom Boutell > P'unk Avenue > 215 755 1330 > punkave.com > window.punkave.com
I don't know about closures but methods are accepted by using Twig_Filter_Method(). the limitation is that it only accepts methods of classes implementing Twig_ExtensionInterface Regards -- Christophe | Stof -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/symfony-devs?hl=en
