Guest User

Untitled

a guest
Jul 16th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. The two templates involved:
  2.  
  3. <script type="text/html" id="js_line_default">
  4. <div class="lzLine">
  5. <% for (var i=0; i < line.nodes.length; i++) { %>
  6. <% var html = line.nodes[i].html(); %>
  7. <%= html %>
  8. <% } %>
  9. </div>
  10. </script>
  11.  
  12. <script type="text/html" id="js_node_default">
  13. <span class="lzNode">
  14. <%= node.text %>
  15. </span>
  16. </script>
  17.  
  18. The two classes involved:
  19.  
  20. var lzLine = function(line, element) {
  21. var that = this;
  22. this.element = element;
  23.  
  24. this.tmpl = "js_line_" + line.tmpl;
  25. this.nodes = [];
  26. var nodes = line.nodes;
  27. for (var i=0; i < nodes.length; i++) {
  28. var thisNode = new lzNode(nodes[i], this);
  29. this.nodes.push(thisNode);
  30. }
  31. this.html = function() { return tmpl('js_line_default', {'line': line}) };
  32. }
  33.  
  34. var lzNode = function(node, line) {
  35. var that = this;
  36. this.tmpl = "js_node_" + node.tmpl;
  37. this.line = line;
  38. this.html = function() { return tmpl('js_node_default', {'node': node}) };
  39. }
Add Comment
Please, Sign In to add comment