<commit_before>from django import template

from ..models import Post

register = template.Library()


@register.assignment_tag
def get_posts(max_posts):
    """
    Returns all Posts
    """
    posts = Post.objects.filter(is_published=True)

    if max_posts and len(posts) > max_posts:
        posts = posts[:max_posts]

    return posts
<commit_msg>template tag fix for django 2.2<commit_after>from django import template

from ..models import Post

register = template.Library()


@register.simple_tag
def get_posts(max_posts):
    """
    Returns all Posts
    """
    posts = Post.objects.filter(is_published=True)

    if max_posts and len(posts) > max_posts:
        posts = posts[:max_posts]

    return posts

{'fraction_non_alphanumeric': 0.09583333333333334, 'fraction_numerical': 0.002777777777777778, 'mean_word_length': 3.4782608695652173, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '106616', 'n_tokens_mistral': 224, 'n_tokens_neox': 214, 'n_words': 59}