Sample usage:
struct Foo { int i; string s; }
auto doc = new Document(" <body> <h1>Foo:</h1> <div class="foo"> <h2 class=".foo-int">(placeholder)</h2> <p class=".foo-str">(placeholder)</p> <hr /> </div> </body> ", true, true);
fill!(Foo[])( doc.requireSelector(".foo"), [Foo(10,"abc"), Foo(20,"def")], (stamp, index, foo) { stamp.requireSelector(".foo-int").innerHTML = text("#", index, " ", foo.i); stamp.requireSelector(".foo-str").innerHTML = foo.s; return stamp; } )
/+ Result: <body> <h1>Foo:</h1> <div class="foo"> <h2 class=".foo-int">#0: 10</h2> <p class=".foo-str">abc</p> <hr /> </div> <div class="foo"> <h2 class=".foo-int">#1: 20</h2> <p class=".foo-str">def</p> <hr /> </div> </body> +/ writeln(doc);
See Implementation
Sample usage:
struct Foo { int i; string s; }
auto doc = new Document(" <body> <h1>Foo:</h1> <div class="foo"> <h2 class=".foo-int">(placeholder)</h2> <p class=".foo-str">(placeholder)</p> <hr /> </div> </body> ", true, true);
fill!(Foo[])( doc.requireSelector(".foo"), [Foo(10,"abc"), Foo(20,"def")], (stamp, index, foo) { stamp.requireSelector(".foo-int").innerHTML = text("#", index, " ", foo.i); stamp.requireSelector(".foo-str").innerHTML = foo.s; return stamp; } )
/+ Result: <body> <h1>Foo:</h1> <div class="foo"> <h2 class=".foo-int">#0: 10</h2> <p class=".foo-str">abc</p> <hr /> </div> <div class="foo"> <h2 class=".foo-int">#1: 20</h2> <p class=".foo-str">def</p> <hr /> </div> </body> +/ writeln(doc);