how to use twig extentions within php? - Symfony2 forum
+ Reply to Thread
Results 1 to 4 of 4
  1. #1

    Join Date
    Mar 2012
    Posts
    2

    Question how to use twig extentions within php?

    Hello,

    i've looked for this subject but couldnt find anything on the internet.

    I wrote an "bbcode" extentions in twig and i want to use it within php / controller as well.

    how do i do that?

    thanks in advance.
    Last edited by mazaka; 03-28-2012 at 11:30 PM.

  2. #2
    Tobias's Avatar

    Join Date
    Jul 2011
    Posts
    95
    Im not to sure what you mean. Your bbcode extensions converts bbcode to HTML. Once your application is in the twig file you can't "go back" into the controller. Look at the application flow.
    Don't reinvent the wheel.
    Tobias

  3. #3

    Join Date
    Mar 2012
    Posts
    2
    i want to re-use the extention within a controller because i want to send a ajax-request to the server with a bbcode-string and the server should return the html-code back. But i didn't really want to create an extra twig-file to convert the bbcode in order to return the html-code. I think i dont have another choice.

  4. #4
    Tobias's Avatar

    Join Date
    Jul 2011
    Posts
    95
    That actually seams to be the right way to do it..

    If you really don't like that solution you may reorganize your code in the twig extension you make just call the twig extension function from your controller.
    Don't reinvent the wheel.
    Tobias

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts