Opened 8 years ago
Closed 7 years ago
#16271 closed enhancement (wontfix)
[CLA] Add some utils to include/parse pieces of template at any time
Reported by: | iDo | Owned by: | iDo |
---|---|---|---|
Priority: | low | Milestone: | future |
Component: | Dijit | Version: | 1.8.1 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
The code attach is intended to be used as a mixin. It give you the possibility to parse a template string at any time during the widget life. It allow using attach point, attach event and everything done by the native parser.
Exemples :
var props = {label: "test" }; //parse subTemplate and populate it with props var node = this.parseTemplate(subTemplate, props); //parse subTemplate, populate it with props and attach it to the domNode. Position is same as domConstruct.place node = this.parseTemplate(subTemplate, props, this.domNode, 'first'); var items = [ {label: "test 1" }, {label: "test 2" } ]; //parse subTemplate for every items and populate it var nodes = this.repeatTemplate(subTemplate, items ); //parse subTemplate for every items, populate it and attach it to the domNode. Position is same as domConstruct.place this.repeatTemplate(subTemplate, props, this.domNode, 'first');
Attachments (3)
Change History (9)
Changed 8 years ago by
Attachment: | _RepeaterMixin.js added |
---|
Changed 8 years ago by
Attachment: | _SplittedTemplateMixin.js added |
---|
comment:1 Changed 8 years ago by
Owner: | changed from bill to iDo |
---|---|
Status: | new → pending |
Changed 8 years ago by
Attachment: | repeaterTest.js added |
---|
comment:2 Changed 8 years ago by
Status: | pending → new |
---|
Attachment (repeaterTest.js) added by ticket reporter.
comment:3 Changed 8 years ago by
For exemple, we use it for populating an <ul> with complex <li>. We put the <li> and all of his children in a separate template, then we call repeatTemplate to attach all needed <li> to the <ul>.
The data used to generate the <li> are mostly comming from a web service.
The attach-point is rewritted to add enfore all attach-point to have an unique name (but I agree it's not mandatory).
I attached a test page.
comment:4 Changed 8 years ago by
OK, thanks for the test page. It's starting to sound like dojox/mvc/Repeat, and also the idea of using mustache or a similar language to support loops and branching in template definitions.
Note also that data-dojo-attach-point is allowed to appear multiple times in a template, and it maps all the attach points into an array of that name.
Anyway, I'll mull this over.
comment:5 Changed 8 years ago by
Milestone: | tbd → future |
---|---|
Priority: | undecided → low |
comment:6 Changed 7 years ago by
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Sorry, I don't think there's enough demand for this to add it to dijit.
Hmm, I'm not sure why you would want something like this. Maybe you can give a bigger example of it being used?
I'm reluctant to add more classes to dijit. I'd be OK with refactoring _TemplatedMixin to expose a static parsing function like your parseTemplate() method, but I don't understand the rhyme or reason for a lot of the stuff your function is doing, like resetting data-dojo-attach-points.