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

<%def name='url(file, raw=False)'><%
try:
    url = staticfiles_storage.url(file)
except:
    url = file
%>${url}${"?raw" if raw else ""}</%def>

<%def name='css(group, raw=False)'>
  % if settings.FEATURES['USE_DJANGO_PIPELINE']:
    ${compressed_css(group, raw=raw)}
  % else:
    % for filename in settings.PIPELINE_CSS[group]['source_filenames']:
      <link rel="stylesheet" href="${staticfiles_storage.url(filename.replace('.scss', '.css'))}${"?raw" if raw else ""}" 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>
