开发者

Symfony + HTML5Boilerplate integration?

开发者 https://www.devze.com 2023-03-20 15:10 出处:网络
Are there any examples out there on how to integrate HTML5Boilerplate into Symfony? The problem that I\'m running into is the way Symfony handles stylesheet and javascript loading.

Are there any examples out there on how to integrate HTML5Boilerplate into Symfony? The problem that I'm running into is the way Symfony handles stylesheet and javascript loading.

Symfony likes you to add your stylesheets and javascript to a special object in the controller (or define them in the view.yml) and then your template/view just call <?php include_stylesheets() ?> and <?php include_javascripts() ?>.

The problem is that the HTML5Boilderplate template wants you to load the Modernizr.min.js in the <head> and all the rest of the javascript files at the end of the </body>. Symfony's magic function wants to just load them all at once though. And I can't seem to figure out a way to selectively load them one at a time in the template.

Also, HTML5Boilerplate has CDN jQuery loading with a dynamic local backup load like this:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.5.1/jqduery.js"></script>
<script>window.jQuery || document.write("<script src='js/backend/libs/jquery-1.5.1.min.js'>\x3C/script>")</script>

Is there anyway to accomplish this in Symfony templates without having to inject the PHP $_SERVER[whatever] into the code?

I feel like I can probably make it all work together but I'm trying to avoid making it too hacky because Symfony uses so many magic methods and voodoo...

开发者_StackOverflow社区

Symfony Version I'm using Symfony 1.4 for this project. The available web host isn't running PHP 5.3.x yet, which is a requirement of Symfony 2.0


If you want to selectively load assets in different locations in the HTML that Symfony 'prefers', you won't be able to use load_javascripts() and load_stylesheets(). I'm not familiar with HTML5Boilerplate, but if you're still using a layout file, why not just manually put the asset includes where you need them to go? This goes against Symfony's way of using view.yml to queue up assets, but sooner or later with any framework you're going to run into cases where you need to do someting your way.

Again, I'm not familiar with HTML5Boilerplate, so if I'm not seeing something, let me know in the comments.


If you are using Symfony 2.0 you should use OryzoneBoilerplateBundle


What version of symfony are you using?

I use html5boilerplate with symfony (2.0) no problem, simply calling the css and javascript straight from a twig template in my resources folder.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号