canton7/fuelphp-casset — Issue #15: Inline JS as dependancy
Author: antitoxic
Created: 2012-02-04 10:10:23+00:00
State: open

### Use case

Hello,
I'm trying to implement **HTML5 boilerplate** layout with Casset asset management.

In the html5 boilerplate template, *jQuery framework* is first atempted to be loaded from google api. Then there's a 1 line inline script that checks whether jQuery was successfully loaded and if not loads the local copy.

The best i could think of was:

* Adding a js group in for jquery from googleapi named `jquery`
* Adding a group for jquery from local copy named `jquery-fallback`
* Then including them via:

```php

','<\\/script>',Casset::render_js('jquery_fallback')))?>')
```

**NOTE**: I use:

```php
Casset::render_js('jquery_fallback')
```
instead of:

```php
Casset::get_filepath_js('jquery.1.7.1.js')
```

because there is **no way** to pass the file as array to `Casset::get_filepath_js` (i.e. `Casset::get_filepath_js(array('jquery.1.7.1.js', 'jquery.1.7.1.min.js'))` which make the file one and the same for all environments.

### The problem

I've made a separate issue for `get_filepath_js()` (#14) so the problem for this lies only in: **Inability to add inline JS as a member of a group - currently every script in a group must be a file location.**

### Proposal

There should be file-specific options where the developer can pass something like `array('script'=>true)` to indicate the file is an inline script.
I can think of of two solutions where of course other can exist.

#### a) Support only runtime definition

This require fix for issue #14 (get_filepath_js)

```php
Casset::js(
sprintf('window.jQuery || document.write(\'