Пример #1
0
    def testJabberwocky(self):
        """
		Tests the tag for pulling jabberwocky
		"""
        graph_range = range(1, 8)
        for graphs in graph_range:
            t = "{% load greeking_tags %}{% jabberwocky " + str(graphs) + " %}"
            ctx, out = self.render(t)
            match = get_jabberwocky_html(get_grafs(graphs))
            self.assertEqual(out, match)
Пример #2
0
def jabberwocky(count=7):
    """
    Prints paragraphs from Lewis Caroll's poem Jabberwocky for greeking
    in templates.

    Usage format::

        {% jabberwocky [count] %}

    ``count`` is a number (or variable) containing the number of paragraphs or
    words to generate (default is 7, which prints the entire poem).

    Examples:
        * ``{% jabberwocky %}`` will output the common "lorem ipsum" paragraph
        * ``{% jabberwocky 3 %}`` will output three paragraphs from the poem
    """
    return get_jabberwocky_html(get_grafs(count or 7))
Пример #3
0
 def testJabberwocky(self):
     """
     Tests the tag for pulling jabberwocky
     """
     from greeking.jabberwocky import get_grafs, get_html
     graph_range = list(range(1, 8))
     for graphs in graph_range:
         t = "{% load greeking_tags %}{% jabberwocky " + str(graphs) + " %}"
         ctx, out = self.render(t)
         match = get_html(get_grafs(graphs))
         self.assertEqual(out, match)
     self.render("{% load greeking_tags %}{% jabberwocky foobar %}")
     self.render("{% load greeking_tags %}{% jabberwocky %}")
     self.assertRaises(
         TemplateSyntaxError,
         self.render,
         "{% load greeking_tags %}{% jabberwocky foo bar %}"
     )
 def render(self, context):
     try:
         count = int(self.count)
     except (ValueError, TypeError):
         count = None
     return get_jabberwocky_html(get_grafs(count))