Giter Club home page Giter Club logo

asset's Introduction

Beautiful Asset

Asset management for Kohana.

The idea

The idea involves Asset_Groups and Assets. An Asset represents one file that needs to be included in an output. I left that previous sentence fairly abstract on purpose. An Asset is simply a resource to be grouped into an Asset_Group.

Usage

You can use this module with or without configuration. Things do get a lot neater and make for easier changes if you do use configuration however do what you will.

Describing an Asset

The first class we'll introduce is Asset. An Asset represents a single file (or asset funnily enough) and can be used to individually render such files.

Take an example of including a CSS file on your web page, you would simply echo the following:

echo new Asset_CSS('css/screen.css');

Asset::__construct() takes a second argument, an array of additional configuration.

echo new Asset_CSS('css/screen.css', array(
	'attributes' => array(
	),
	'cache_buster' => TRUE,
));

``` php
<?php
echo new Asset_Group(array(
	new Asset_CSS('css/screen.css'),
	new Asset_CSS('css/print.css', array('media' => 'print')),
	new Asset_Less('css/testing.less'),
));

Using the default Kohana config reader you could have described this like so:

<?php
return array(
	'groups' => array(
		'stylesheets' => array(
			array('CSS', 'css/screen.css'),
			array('CSS', 'css/print.css', array(
				'attributes' => array(
					'media' => 'print',
				),
			),
			array('LESS', 'css/testing.less'),
		),
	),
);

And then only had to do this in your PHP:

<?php
echo new Asset_Group('stylesheets');

So really it's up to you.

Asset Types

These Asset types will be shipped when complete:

  • JavaScript
  • Cascading StyleSheets
  • Less
  • Coffee

Asset Caching

For use in production environement you can now use Asset_Cache. It is basically a handy decorator for caching your asset compilations.

<?php
echo new Asset_Cache(new Asset_Group('javascripts'));

// Or 
echo Asset_Cache::group('javascripts');

Warning

This module is still in development currently.

Author

Luke Morton

License

MIT

asset's People

Contributors

lukemorton avatar davidwinter avatar

Stargazers

Sheik Nizamuddin avatar Angus H. avatar yycmmc avatar Henry avatar Maks avatar  avatar Recca Tsai avatar totsapon keawsarn avatar Andrew Coulton avatar Ignacio Muñoz Fernández avatar Jarod Law Ding Yong avatar  avatar Ralf Blumenthal avatar Shawn Sprehe avatar  avatar Razvan avatar Alessandro Frangioni avatar Daniel Lo Nigro avatar Anton Schetilov avatar Mathew Davies avatar  avatar

Watchers

Razvan avatar James Cloos avatar

asset's Issues

Filter individual files

Should be able to filter individual files before applying group filters. Probably in the following fashion:

$less = new Asset_Less('css/print.less', array('media' => 'print'));
$less->add_filter('Less');
$css = $less->filter(); // now a Asset_CSS is returned
echo $css;

Although perhaps the $less->html() method could filter and echo the Asset_CSS version itself. Not sure.

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.