Source: panels/keyboard_add_layouts/nested_template_factory.js

  1. /**
  2. * This is a factory method that returns a template function that is able to
  3. * render nested lists. The constructor takes two template functions. One for
  4. * the first level item and one for the second level item. The created inner
  5. * list views is exposed via the listViews property.
  6. *
  7. * @module keyboard_add_layouts/nested_template_factory
  8. */
  9. define(function(require) {
  10. 'use strict';
  11. return function ctor_nestedTemplate(parentTemplate, childTemplate) {
  12. var listViews = [];
  13. var template = parentTemplate.bind({
  14. listViews: listViews,
  15. childTemplate: childTemplate
  16. });
  17. // Expose the list views.
  18. Object.defineProperty(template, 'listViews', {
  19. configurable: false,
  20. get: function() {
  21. return listViews;
  22. }
  23. });
  24. return template;
  25. };
  26. });