<commit_before><commit_msg>Add template tag to get featured products for a list of categories<commit_after>from django import template

import plata


register = template.Library()


@register.simple_tag
def featured_products_for_categories(category_list, variable_name='featured_product'):
    """
    {% featured_products_for_categories category_list "variable_name" %}
    """

    category_list = list(category_list)

    for category in category_list:
        try:
            setattr(category, variable_name, category.products.featured()[0])
        except IndexError:
            pass

    return u''

{'fraction_non_alphanumeric': 0.0805921052631579, 'fraction_numerical': 0.001644736842105263, 'mean_word_length': 3.911290322580645, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5705064', 'n_tokens_mistral': 167, 'n_tokens_neox': 159, 'n_words': 41}