The head, style and body parameters can be used to insert custom HTML in the template. You can pass any optional parameter that can also be passed to render().
(graph, head="", style="", body=("",""), **kwargs)
| 26 | '''.strip() |
| 27 | |
| 28 | def webpage(graph, head="", style="", body=("",""), **kwargs): |
| 29 | """ The head, style and body parameters can be used to insert custom HTML in the template. |
| 30 | You can pass any optional parameter that can also be passed to render(). |
| 31 | """ |
| 32 | s1 = render(graph, type=STYLE, **kwargs) |
| 33 | s2 = render(graph, type=CANVAS, **kwargs) |
| 34 | # Fix HTML source indentation: |
| 35 | # f1 = indent each line |
| 36 | # f2 = indent first line |
| 37 | f1 = lambda s, t="\t": s.replace("\n","\n"+t) |
| 38 | f2 = lambda s, t="\t": ("\n%s%s" % (t,s.lstrip())).rstrip() |
| 39 | return template % ( |
| 40 | f2(head), f1(s1), f2(style, "\t\t"), f1(body[0]), f1("\n"+s2), f2(body[1])) |
| 41 | |
| 42 | # Create a graph: |
| 43 | g = Graph() |
no test coverage detected
searching dependent graphs…