Giter Site home page Giter Site logo

Conditional Stylesheets about fuelphp-casset HOT 3 OPEN

canton7 avatar canton7 commented on June 18, 2024
Conditional Stylesheets

from fuelphp-casset.

Comments (3)

canton7 avatar canton7 commented on June 18, 2024

There's nothing built-in which specifically targets this scenario. However, groups can provide a solution. Something like (untested):

// config.php
'groups' => array(
    'css' => array(
        'my_group' => array(
            'files' => array(
                'stylesheet_for_all_browsers.css',
            ),
            'enabled' => false,
            'deps' => array('my_group_ie6'),
        ),
       'my_group_ie6' => array(
            'files' => array(
                'stylesheet_for_ie6.css',
            ),
            'enabled' => false,
        ),
    ),
),

When you Casset::enable_css('my_group'), the ie6-only group will also be enabled. If my_group is enabled to start with, you might not want to bother with the dependency stuff..

<!-- Your template -->

<!-- Render the ie6-specific group first, then it won't be rendered when you do the rest -->

<!-- [if IE6] -->
<?php echo Casset::render_css('my_group_ie6'); ?>
<![endif]-->

<?php echo Casset::render_css(); ?>

A better solution would be to add a magic value to the 'attr' property for a group (for example, 'attr' => array('ieif' => 'lt IE6'), then remove it around line 894, and add the corresponding conditional comments on lines 913, 921, 935, and 944. You'd still have to have two groups (doing this at a sub-group level is a nightmare, due to the complexity of combining ie6-only and all-browser stylesheets), but at least the conditional comments would be automatic. Of course there's a potential gotcha if the person has gen_tags disabled.... Pull requests gladly accepted :)

from fuelphp-casset.

canton7 avatar canton7 commented on June 18, 2024

Another thought - we'd need to support both downlevel-hidden and downlevel-revealed comments. They could have different keys in $attr, but then someone could specify both... hrm...

from fuelphp-casset.

leemason avatar leemason commented on June 18, 2024

you dont need to do this anyway, use the brilliant Agent class built into fuel

if (Agent::browser() == 'IE' and Agent::version() < 9){
   //addyour assets here
}

from fuelphp-casset.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.