Giter Site home page Giter Site logo

codeigniter-assets-helper's Introduction

CodeIgniter-Assets-Helper

Helper to load assets (images, stylesheets or javascript).

Requirements

  • CodeIgniter should be configured to load url_helper automatically.

Installation

Copy assets_helper.php into the applications/helpers directory and copy assets.php into the applications/config directory.

Configuration

You need to set your assets folder for each type (images, stylesheets or javascript). See applications/config/assets.php for more information.

Usage

One file without custom attributes:

assets_css('example.css')

# Results in
<link rel="stylesheet" type="text/css" href="http://www.website.com/assets/css/example.css">
assets_js('example.js')

# Results in
<script type="text/javascript" src="http://www.website.com/assets/js/example.js"></script>
assets_img('example.png')

# Results in
<img src="http://www.website.com/assets/img/example.png"/>

One file with optional custom attributes

assets_css('example.css', array('media' => 'screen')
# Results in
<link rel="stylesheet" type="text/css" href="http://www.website.com/assets/css/example.css" media="screen">
assets_js('example.js', array('charset' => 'utf-8')
# Results in
<script type="text/javascript" src="http://www.website.com/assets/js/example.js" charset="utf-8"></script>
assets_img('example.png', array('title' => 'Awesome Helper')
# Results in
<img src="http://www.website.com/assets/img/example.png" title="Awesome Helper"/>

Multiple files, with or without custom attributes

$multiple_css = array('example.css', 'style.css');
assets_css($multiple_css); 
# Results in
<link rel="stylesheet" type="text/css" href="http://www.website.com/assets/css/example.css">
<link rel="stylesheet" type="text/css" href="http://www.website.com/assets/css/style.css">
$multiple_js = array('example.js', array('style.js', array('charset' => 'utf-8')));
assets_js($multiple_js);
# Results in
<script type="text/javascript" src="http://www.website.com/assets/js/example.js"></script>
<script type="text/javascript" src="http://www.website.com/assets/js/style.js" charset="utf-8"></script>
$multiple_img = array(array('example.png', array('alt' => 'ranisalt rules')), array('style.css', array('title' => 'Awesome Helper')));
assets_img($multiple_img);
# Results in
<img src="http://www.website.com/assets/img/example.png" alt="ranisalt rules"/>
<img src="http://www.website.com/assets/img/style.css" title="Awesome Helper"/>

You probably got the hang of it.

codeigniter-assets-helper's People

Contributors

drpcken avatar gpedro avatar mameaw14 avatar ranisalt avatar

Watchers

 avatar  avatar  avatar

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.