def pangram(language='en'):
    """
    Prints a pangram in the specified language.

    A pangram is a phrase that includes every letter of an alphabet.

    Default is English. For a full list of available languages,
        refer to pangrams.py

    Usage format::

        {% pangram [language] %}

    ``language`` is the two-letter abbreviation the desired language.

    Examples:
        * ``{% pangram %}`` will output the default English pangram.
        * ``{% pangram 'fr' %}`` will output a French pangram.
    """
    try:
        pangram = get_pangram(language)
    except KeyError:
        raise template.TemplateSyntaxError(
            "Could not find a pangram for %r abbreviation" % language
        )
    return get_pangram_html(pangram)
 def render(self, context):
     try:
         pangram = get_pangram(self.language)
     except KeyError:
         raise template.TemplateSyntaxError(
             "Could not find a pangram for %r abbreviation" % self.language
         )
     return get_pangram_html(pangram)
Example #3
0
    def testPangrams(self):
        """
		Tests the tag for pulling pangrams
		"""
        languages = PANGRAMS.keys()
        for language in languages:
            t = "{% load greeking_tags %}{% pangram " + language + " %}"
            ctx, out = self.render(t)
            match = get_pangram_html(get_pangram(language))
            self.assertEqual(out, smart_unicode(match))