Giter Site home page Giter Site logo

rbhushan90 / assets Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bradstinson/assets

0.0 1.0 0.0 416 KB

A simple assets library that combines, minifies, and caches CSS, JS, Less, and CoffeeScript assets on the fly.

PHP 99.12% CSS 0.73% CoffeeScript 0.15%

assets's Introduction

Assets

Build Status

Assets is yet another CSS/JavaScript minificaton and combination library. However, unlike most other libraries (which rely on Assetic), this ones takes a more simplistic approach.

Assets supports minifying and combining stylesheets and scripts, in an effort to reduce the number and size of http requests needed to load a given page. The generated file is also cached, which prevents an application from having to generate the same file for every new request.

Basic usage

CSS

CSS files can be added using the following command, where "file1.css" and "file2.css" are the CSS files you want to include, and are located at assets/css/file1.css and assets/css/file2.css.

Assets::css('file1.css');
Assets::css('file2.css');

You may also submit files as an array.

Assets::css(array('file1.css', 'file2.css'));

Assets will minify both CSS files and combine them into a single file (which is written to 'assets/cache' directory). The proper tags will then be returned. To include this file in your page, use the following:

echo Assets::renderCss();
/*
Returns something like:
<link rel="stylesheet" href="/assets/cache/3cf89b9f723e22c1caf26f8d4d1fdc31.css">
*/

LESS

Less files can be added using the following command, where "file1.less" is the Less file you want to compile, and is located at assets/css/file1.less.

Assets::less('file1.less');

You may also submit multiple files as an array.

Assets::css(array('file1.less', 'file2.less'));

Your Less files will be automatically compiled and combined with your CSS files into a single file (which is written to 'assets/cache' directory). The proper tags will then be returned.

JS

Javascript files can be added using the following command, where "file1.js" and "file2.js" are the javascript files you want to include, and are located at assets/js/file1.js and assets/js/file2.js.

Assets::js('file1.js');
Assets::js('file2.js');

You may also submit files as an array.

Assets::js(array('file1.js', 'file2.js'));

Assets will minify both JS files and combine them into a single file (which is written to 'assets/cache' directory). The proper tags will then be returned. To include this file in your page, use the following:

echo Assets::renderJs();
/*
Returns something like:
<script src="/assets/cache/9cf2803d8f075cb7d1ad31940738f35e.js"></script>
*/

CoffeeScript

CoffeeScript files can be added using the following command, where "file1.coffee" is the CoffeeScript file you want to compile, and is located at assets/js/file1.coffee.

Assets::coffee('file1.coffee');

You may also submit multiple files as an array.

Assets::coffee(array('file1.coffee', 'file2.coffee'));

Your CoffeeScript files will be automatically compiled and combined with your JS files into a single file (which is written to 'assets/cache' directory). The proper tags will then be returned.

If you would like to generate the CSS and JS tags together, you can call:

echo Assets::render();
/*
Which will return:
<link rel="stylesheet" href="/assets/cache/3cf89b9f723e22c1caf26f8d4d1fdc31.css">
<script src="/assets/cache/9cf2803d8f075cb7d1ad31940738f35e.js"></script>
*/

Configuration

By default, this library assumes the following directory structure:

assets/
   css/
   js/
   cache/
   

However, you are now able to adjust the path to the assets directory (if needed):

Assets::setPath('public/assets/');

BaseURL

Assets::setBaseurl('/');

Groups

This library currently does not offer support for groups. This is because the project I was working on did not require it. If enough requests are made, this may be added in a future version.

Thanks

This asset library was inspired by and uses components from the following libraries:

Contributing

If you have any issues/complaints/suggestions, let me know and I will see if I can implement them as time permits. Also, pull requests are also welcome.

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.