Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
6867 Zobrazení

Hi,

I want to achieve report page count in .mako file of webkit reports, as it is in standard webkit footer (in xml). Following footer example, I have tried this in .mako (output is "Number of pages: undefined"):

<html>
<head>
<script>
    function subst() {
    var vars={};
    var x=document.location.search.substring(1).split('&');
    for(var i in x) {var z=x[i].split('=',2);vars[z[0]] = unescape(z[1]);}
    var x=['frompage','topage','page','webpage','section','subsection','subsubsection'];
    for(var i in x) {
    var y = document.getElementsByClassName(x[i]);
    for(var j=0; j<y.length; ++j) y[j].textContent = vars[x[i]];
        }
    }
</script>
<style type="text/css">
${css}
</style>
</head>
<body onload="subst()">
%for o in objects:
<p>Number of pages: <span class="topage"/> </p>
%endfor
</body>
</html>

Many thanks in advance!

Avatar
Zrušit
Nejlepší odpověď

To my knowledge this is not possible since the header and footer get parsed separately from the mako through a different procedure.The header and footer have access to this information since they get parsed at the initial stages, after which mako is used and concatenated

I really hope I am wrong but my investigations revealed this so far

Avatar
Zrušit
Nejlepší odpověď

webkir report use the mako template, the mako template allows you to use inside a loop the magic variable loop

Page ${loop.index+1} of ${len(objects)}

look at: --docs.makotemplates.org/en/latest/runtime.html#mako.runtime.LoopContext

for more datails

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
4
pro 23
29418
1
led 24
4317
1
srp 16
10762
7
bře 15
6302
1
bře 15
9438