canton7 / fuelphp-casset

Better asset management library for fuelphp (with minification!)
MIT License
103 stars 29 forks source link

add support for head/footer locations #48

Open leemason opened 10 years ago

leemason commented 10 years ago

just a quick one which ive added to my app.

i needed to be able to set js for the head, and for the footer sections of the site, so this is how ive added it:

in the head section.

if(Casset::group_exists('js', 'footer')){
    Casset::set_js_option('footer', 'enabled', false);
}
echo Casset::render_js();

in the footer section

if(Casset::group_exists('js', 'footer')){
    Casset::set_js_option('footer', 'enabled', true);
}
echo Casset::render_js();

ive actually added this using the Event class for fuel, but it would work by just putting this in the view files too.

namepsaces still work fine, so files can still come from custom locations.

this works fine for me, but maybe some "global" footer/head groups could be created to prevent the need to check if the group exists first (without the checks the class throws an exception)

or event better add a var in the render function which allows us to set if the call in the head or footer, like:

echo Casset::render_js(false, true);

where true means we are in the footer.