#15118 closed feature (fixed)
Declarative Require for Parser
Reported by: | Kitson Kelly | Owned by: | bill |
---|---|---|---|
Priority: | undecided | Milestone: | 1.8 |
Component: | Parser | Version: | 1.7.2 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
The parser should allow declarative requirements to be used in markup. For example:
<div data-dojo-require="package/module" data-dojo-args="module"></div> <div data-dojo-type="module"></div> <div data-dojo-require="package/module2"></div> <div data-dojo-type="package/module2"></div> <div data-dojo-require="package/module3,package/module4" data-dojo-args="module3, module4"></div> <div data-dojo-type="module3" data-dojo-mixins="module4"></div>
I have a patch for this currently at: https://github.com/kitsonk/dojo/commit/74d293d33354332ed999d997b5739c3de4e109eb. I will create a discreet patch and attach it to the ticket after discussion and review.
Attachments (5)
Change History (22)
Changed 9 years ago by
Attachment: | declarative_require.patch added |
---|
Changed 9 years ago by
Attachment: | declarative_require.2.patch added |
---|
Enhances the parser by allowing a declarative require
comment:2 Changed 9 years ago by
Patch 2 adds the following:
- data-dojo-props will be evaluated within the scope of the declarative requires.
- declarative scripting will be evaluated within the scope of the declarative requires.
So all of the following is now possible:
<div data-dojo-require="dojo/on, dijit/registry, dijit/form/Button" data-dojo-args="on, registry, Button"></div> <button id="b1" type="button" data-dojo-type="Button"> <span>Button</span> <script type="dojo/on" data-dojo-event="click" data-dojo-args="e"> on(registry.byId("someWidget"), "click", function(e) { console.log("foo"); }); </script> </button> <div data-dojo-type="Button" data-dojo-props="label: registry.byId('b1').get('label')"></div>
Changed 9 years ago by
Attachment: | declarative_require.3.patch added |
---|
Adds AMD Declarative Require Sytax to dojo/parser
comment:3 Changed 9 years ago by
Patch 3 changes the syntax of declarative requires and adds declarative defines.
All of the following would be possible now:
<script type="amd/require" data-amd-mids="dojo/on, dijit/registry, dijit/form/Button" data-amd-args="on, registry, Button"> var button1 = new Button({}, "b1"); </script> <button id="b1" type="button">Button 1</button> <button id="b2" type="button" data-dojo-type="Button"> <span>Button 2</span> <script type="dojo/on" data-dojo-event="click" data-dojo-args="e"> on(registry.byId("b1"), "click", function(e) { console.log("foo"); }); </script> </button> <button type="button" data-dojo-type="Button" data-dojo-props="label: registry.byId('b1').get('label')"></div>
comment:4 Changed 9 years ago by
See also #13779, since this patch is mainly about adding a scope to the parser, although not in the normal sense of a scope that only applies to a single parse() call.
comment:7 Changed 9 years ago by
drequire_dojo.patch
modifies dojo/parser
and dojo/html
.
I hadn't noted before that the following is possible (there by answering the question of how to use dojo/on
in declarative scripting).
<script type="amd/require" data-amd-mids="dojo/on, dojo/dom" data-dojo-args="on, dom"> exports.on = on; exports.dom = dom; </script> <!-- or --> <script type="amd/require" data-amd-mids="dojo/on" data-amd-return="on"></script> <script type="amd/require" data-amd-mids="dojo/dom" data-amd-return="dom"></script> <!-- and then --> <button type="button" data-dojo-type="dijit/form/Button"> <span>Click!</span> <script type="dojo/on" data-dojo-event="click"> on(dom.byId("something"), "click", function(){ console.log("hello") }); </script> </button>
I also need to provide an update to dijit/layout/ContentPane
so it handles the promise parse() return.
Changed 9 years ago by
Attachment: | doh_decl-require_dijit.patch added |
---|
DOH ContentPane? test case for Declarative Require
comment:10 Changed 9 years ago by
Attached unit test case for Declarative Require for dijit/layout/ContentPane
comment:11 Changed 9 years ago by
Milestone: | tbd → 1.8 |
---|---|
Type: | enhancement → feature |
Patch including unit tests