Question

OK, so I'm using HTML5 Boilerplate to minify css, js and html which is placed within my PHP files.

Using the build script I can successfully create a publish folder and the css and js and even the php code is minified. Good so far.

However, there is a discrepancy with the output specifically single and double quotes in my link tags? For some reason it deals with the first link tag fine and then struggles with the second link tag. As you can imagine this causes significant problems when rendering in the browser.

Here's the code pre-build:

<link rel="stylesheet" href="<?php echo base_url('styles/normalize.css');?>">
<link rel="stylesheet" href="<?php echo base_url('styles/main.css');?>">
<script src="<?php echo base_url('js/vendor/modernizr-2.6.2.min.js');?>"></script>

And then after using the build script. NB. The single quote inserted in the second link tag href.

<link rel="stylesheet" href="http://localhost/styles/normalize.css">
<link rel="stylesheet" href='http://localhost/styles/be5c719.css">
<script src="http://localhost/js/vendor/modernizr-2.6.2.min.js"></script>

It could be argued that I don't need to have the php base_url() function thus keeping it relative, however this shouldn't make a difference should it? Is there something in the configuration files I have missed?

Was it helpful?

Solution

If you want matching quotes and are happy removing the echo base_url piece, simply ensure the quotes in the replace in these lines are double instead of single quotes. We were simply inconsistent there and this is the first time it's been pointed out.

https://github.com/h5bp/ant-build-script/blob/master/build.xml#L692-L696

And then please submit a pull request so everyone can have some consistency in their lives. :)

I'm not sure what's happening in your first example. The replace (as you can see) just uses single quotes. If we were mismatching them for everyone there'd be a lot more noise around it. I'll have to test it. Feel free to open an issue on the repo so that I have something to track to.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top