Giter Club home page Giter Club logo

madnatter_template_lib's Introduction

Mad Natter Template Library

A simple template library for Codeigniter

Copyright (C) <2012-2013>  <Kyle Coots>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

An open source Template Library for PHP 5.1.6 or newer

@package  	MadNatter_Template_Lib
@author		Kyle Coots
@copyright	Copyright (c) 2012 - 2013, Mad Natter
@since		Version 1.0
@filesource https://github.com/snowballrandom/MadNatter_Template_Lib/

More complete tutorial can be found over at my blog site http://www.snowballrandom.com/mad-natter-template-library-for-codeigniter/

How to use the Mad Natter Templae Library

We start by loading the template library

$this->load->library('template');

Or

$autoload['libraries'] = array('template');

Now that we have the library loaded we can use it like this.

$template_data = $this->template->load('welcome_message');

$this->load->view($template_data->template, $template_data);

Adding Css

You css files should be in the directory "/assets/css/".

If your file is in a different location you can use the second param to allow you to specify the exact location. Note: you will need to specify the absolute url if using the second param.

$this->template->addcss($src, $remote, $attr);

Local file in the "/assets/css/" directory

$this->template->addcss('my_css');

Notice that there isn't a need to specify the extension (i.e. "my_css.css")

Loading a remote file or file with different extension

$this->template->addcss('http://www.example.com/somefolder/someplace/my_css.css', true);

Adding extra attributes to the link tag for you css file. You can use an array() or an object.

$attr = array('charset'=>'utf-8');

$this->template->addcss('my_css', false, $attr);

Will produce:

<link rel="stylesheet" type="text/css" href="http://localhost/assets/css/my_css.css" charset="utf-8" / >

Adding Javascript

Adding Java script is exactly the same as adding css

$this->template->addjs($src, $remote, $attr);

Adding Meta

$this->template->addmeta($meta);

Adding meta is as simple as passing an array or object to the function

$meta = array('charset'=>'utf-8');
$this->template->addmeta($meta);

Will produce:

<meta charset="utf-8" >

Or

$meta = new stdClass;
$meta->charset = 'utf-8';
$this->template->addmeta($meta);

Will produce:

<meta charset="utf-8" >

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.