Posted By

lfatr on 02/16/10


Tagged


Versions (?)

KIT RHINO


 / Published in: JavaScript
 

  1. -- check mode --
  2.  
  3. <?js if (kit.mode=="publish") { ?>
  4. <div>only display this in publish mode</div>
  5. <?js } else { ?>
  6. <div>display this otherwise</div>
  7. <?js } ?>
  8.  
  9. -- loop --
  10.  
  11. <?js for (var i=0;i<10;i++) { ?>
  12. <div id="{i}">Value of i is: <?js=i?></div>
  13. <? } ?>
  14.  
  15. -- Packages --
  16. {
  17. color: "blue",
  18. sayHello: function (who) {
  19. // nb "out" is always accessible and is in the top-level scope.
  20. out.write("Hello " + who);
  21. },
  22. itemName: function () {
  23. // return the name of the item currently being rendered.
  24. // nb "item" is always accessible and is in the top-level scope.
  25. return item.name;
  26. },
  27. sameColor: function (c) {
  28. return (this.color == c);
  29. }
  30. }
  31.  
  32. to access these use:
  33. MyPackage.color
  34. MyPackage.sayHello("kieran")
  35. MyPackage.itemName()
  36. MyPackage.sameColor("red")
  37.  
  38. self referring:
  39. {
  40. SubObject: function () {
  41. this.x = "x";
  42. },
  43. func: function () {
  44. return new this.SubObject();
  45. }
  46. }
  47.  
  48. -- LOGGING FROM WORKFLOWS --
  49. log.debug("Blah");
  50. out.writeln("Blah");

Report this snippet  

You need to login to post a comment.