/ Published in: JavaScript
Expand |
Embed | Plain Text
-- check mode -- <?js if (kit.mode=="publish") { ?> <div>only display this in publish mode</div> <?js } else { ?> <div>display this otherwise</div> <?js } ?> -- loop -- <?js for (var i=0;i<10;i++) { ?> <div id="{i}">Value of i is: <?js=i?></div> <? } ?> -- Packages -- { color: "blue", sayHello: function (who) { // nb "out" is always accessible and is in the top-level scope. out.write("Hello " + who); }, itemName: function () { // return the name of the item currently being rendered. // nb "item" is always accessible and is in the top-level scope. return item.name; }, sameColor: function (c) { return (this.color == c); } } to access these use: MyPackage.color MyPackage.sayHello("kieran") MyPackage.itemName() MyPackage.sameColor("red") self referring: { SubObject: function () { this.x = "x"; }, func: function () { return new this.SubObject(); } } -- LOGGING FROM WORKFLOWS -- log.debug("Blah"); out.writeln("Blah");
You need to login to post a comment.
