Skip to content

Instantly share code, notes, and snippets.

@ruthlessfish
Created August 29, 2011 00:01
Show Gist options
  • Save ruthlessfish/1177426 to your computer and use it in GitHub Desktop.
Save ruthlessfish/1177426 to your computer and use it in GitHub Desktop.
serve assets with correct content type header
<?php defined('BASEPATH') OR exit('No direct script access allowed');
if( ! function_exists('show_css'))
{
function show_css($content)
{
show_output('text/css', $content);
}
}
// --------------------------------------------------------------------
if( ! function_exists('show_js'))
{
function show_js($content)
{
show_output('text/javascript', $content);
}
}
// --------------------------------------------------------------------
if( ! function_exists('show_json'))
{
function show_json($data)
{
show_output('application/json', json_encode($data));
}
}
// --------------------------------------------------------------------
if( ! function_exists('show_output'))
{
function show_output($content_type, $content)
{
get_instance()->output->set_content_type($content_type)
->set_output($content);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment