Disable CSS stylesheet for a specific action in Symfony

后端 未结 3 1680
深忆病人
深忆病人 2021-01-05 09:32

Is there any way of disabling a stylesheet in view.yml for a specific action in Symfony?

For example I\'ve got this in my view.yml:

default:
  style         


        
3条回答
  •  一个人的身影
    2021-01-05 10:06

    I'm not 100% certain, but I believe the compiled view.yml file is processed before execution of the action. If that's true, you can do:

    public function executeDisplay()
    {
      $this->response->removeStylesheet('default.css');
    }
    

    I find view.yml to be a little inflexible. You may find it easier to have a global "head" template that gets included in your layout(s). Then you can check sfConfig values to see if you should include individual files, making it easier to turn them on and off.

提交回复
热议问题