Skip to content

Instantly share code, notes, and snippets.

@fabe
Last active November 4, 2015 17:34
Show Gist options
  • Save fabe/24996ad922520034fce7 to your computer and use it in GitHub Desktop.
Save fabe/24996ad922520034fce7 to your computer and use it in GitHub Desktop.
Cactus plugin: easy including of CSS inside HTML (faster for smaller sites).
import sys
from cactus.template_tags import register
# Easy including of CSS inside HTML (faster for smaller sites).
# Usage: {% print_file "path/to/stylesheet.css" %}
@register.simple_tag
def print_file(path):
try:
file = open(path).read().decode()
return file
except:
sys.exit("Error: File could not be found/read ('" + path + "').")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment