コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
6898 ビュー

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!

アバター
破棄
最善の回答

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

アバター
破棄
最善の回答

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

アバター
破棄
関連投稿 返信 ビュー 活動
4
12月 23
29579
1
1月 24
4379
1
8月 16
10822
7
3月 15
6405
1
3月 15
9497