<%!
from staticfiles.storage import staticfiles_storage
from pipeline_mako import compressed_css, compressed_js
%>

<%def name='url(file)'><%
try:
    url = staticfiles_storage.url(file)
except:
    url = file
%>${url}</%def>

<%def name='css(group)'>
  % if settings.FEATURES['USE_DJANGO_PIPELINE']:
    ${compressed_css(group)}
  % else:
    % for filename in settings.PIPELINE_CSS[group]['source_filenames']:
      <link rel="stylesheet" href="${staticfiles_storage.url(filename.replace('.scss', '.css'))}" type="text/css" media="all" / >
    % endfor
  %endif
</%def>
<%def name='js(group)'>
  % if settings.FEATURES['USE_DJANGO_PIPELINE']:
    ${compressed_js(group)}
  % else:
    % for filename in settings.PIPELINE_JS[group]['source_filenames']:
      <script type="text/javascript" src="${staticfiles_storage.url(filename.replace('.coffee', '.js'))}"></script>
    % endfor
  %endif
</%def>

<%def name="include(path)"><%
from django.template.loaders.filesystem import _loader
source, template_path = _loader.load_template_source(path)
%>${source}</%def>
