jonkemp / gulp-useref

Parse build blocks in HTML files to replace references to non-optimized scripts or stylesheets.
MIT License
705 stars 93 forks source link

Add trailing and ending string to src and href attribute #129

Closed samhenri closed 8 years ago

samhenri commented 8 years ago

I'm creating pages for some sort of template engine in Python. All assets (src and href attributes) must start with $href(' and end with '). Right now using <!-- build:css --> and <!-- build:js --> are working fine and putting my assets in the right places, but the html template output url's are all absolute or relative paths. Is it possible to change useref "template" for <script> and <link> tags? For instance:

`

<!-- endbuild -->
<!-- build:js libs/modernizr.js -->
<script src="/bower_components/modernizr/modernizr.js"></script>
<!-- endbuild -->`

... would put the file in libs/themes/base/ folder, but the outputted html would be something like:

<link rel="stylesheet" href="$href('libs/themes/base/jquery-ui.css')"> instead of <link rel="stylesheet" href="libs/themes/base/jquery-ui.css"> or <script src="$href('libs/modernizr.js')"></script> instead of <script src="libs/modernizr.js"></script>

jonkemp commented 8 years ago

No, but you could use another step in the task after gulp-useref and use gulp-replace to update the templates.

samhenri commented 8 years ago

I tried using gulp-replace-html with no luck, with just two lines and a regex I did it with gulp-replace. Thanks!