from django import template
from django.shortcuts import render
from blog.models import Post
from django.contrib.auth.models import User
register=template.Library()
@register.simple_tag
def total_posts():
	count = Post.objects.all().count()
	return count
	
@register.simple_tag
def total_users():
	user = User.objects.all().count()
	return user
	
@register.inclusion_tag('blog/latest_posts.html')
def	show_latest_posts(count=5):

				latest_posts	=Post.objects.filter(published=True).order_by('-created_on')[:count]

				return	{'latest_posts':	latest_posts}




#from	django.utils.safestring	import	mark_safe

# import	markdown

# @register.filter(name='markdown')

# def	markdown_format(text):

				# return	mark_safe(markdown.markdown(text))