templates and place holders

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

templates and place holders

denov
All,

Is there a way to use _TemplateMixin (mostly _stringRepl)and and
dojo/text to load some markup, do some variable substitution to produce
a dom node?  I'm trying to avoid have lots of little bits of markup in
my widget code.


Thanks,
Deno



--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: templates and place holders

Karl Tiedt
By widget code do you mean your widget template? Because... That is the intended purpose of the widget templates...

-Karl Tiedt

On Fri, Jul 10, 2015 at 3:11 PM, Deno Vichas <[hidden email]> wrote:
All,

Is there a way to use _TemplateMixin (mostly _stringRepl)and and
dojo/text to load some markup, do some variable substitution to produce
a dom node?  I'm trying to avoid have lots of little bits of markup in
my widget code.


Thanks,
Deno



--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest


--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: templates and place holders

dylanks
In reply to this post by denov
Meaning sort of like a sub-template or ?

You can always use dojo/text to load an HTML fragment, then do
dojo/string/substitute to replace tokens within that markup, and then do
dojo/dom-construct.toDom or dojo/dom-construct.place to them convert it
to a dom node. This is roughly what _TemplatedMixin does, but is
generally just one template per widget.

on 7/10/15, 15:11 (GMT-07:00) Deno Vichas said the following:

> All,
>
> Is there a way to use _TemplateMixin (mostly _stringRepl)and and
> dojo/text to load some markup, do some variable substitution to produce
> a dom node?  I'm trying to avoid have lots of little bits of markup in
> my widget code.
>
>
> Thanks,
> Deno
>
>
>

--
Dylan Schiemann
SitePen, Inc.
Dojo workshops in the US, Canada, and Europe:
http://www.sitepen.com/workshops/
http://www.sitepen.com/

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Co-Founder, Dojo Toolkit
CEO, SitePen, Inc.  http://www.sitepen.com/
Reply | Threaded
Open this post in threaded view
|

Re: templates and place holders

denov
In reply to this post by Karl Tiedt
So in one use case I've been building some forms where I need to display tabular data.   It seems a bit heavy to need to build another widget.  Maybe I'm just being a lazy here..  And I really dislike having any markup at all in my code.  So I'm wanting a way to keep markup in html and being able to use is to build little bits of the dom for a widget.

I think I want something like this -

// template load via dojo/text

Array.forEach(data.ArrayOfThings, function(obj){ domContrust.toDomFromTemplate(template, obj) })


I've start on some code for this.   I'll share once I get something worth while.


- Deno



On 7/10/2015 4:45 PM, Karl Tiedt wrote:
By widget code do you mean your widget template? Because... That is the intended purpose of the widget templates...

-Karl Tiedt

On Fri, Jul 10, 2015 at 3:11 PM, Deno Vichas <[hidden email]> wrote:
All,

Is there a way to use _TemplateMixin (mostly _stringRepl)and and
dojo/text to load some markup, do some variable substitution to produce
a dom node?  I'm trying to avoid have lots of little bits of markup in
my widget code.


Thanks,
Deno



--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest





--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: templates and place holders

dylanks
With dojo/string.substitute, you could just do:

Array.forEach(dataArray, function(obj) {
        domConstruct.toDom(string.substitute(template, obj)):
        // or domConstruct.place(string.substitute(template, obj), nodeRef,
position):
}

on 7/11/15, 10:14 (GMT-07:00) Deno Vichas said the following:

> So in one use case I've been building some forms where I need to display
> tabular data.   It seems a bit heavy to need to build another widget.
> Maybe I'm just being a lazy here..  And I really dislike having any
> markup at all in my code.  So I'm wanting a way to keep markup in html
> and being able to use is to build little bits of the dom for a widget.
>
> I think I want something like this -
>
> // template load via dojo/text
>
> Array.forEach(data.ArrayOfThings, function(obj){
> domContrust.toDomFromTemplate(template, obj) })
>
>
> I've start on some code for this.   I'll share once I get something
> worth while.
>
>
> - Deno
>
>
>
> On 7/10/2015 4:45 PM, Karl Tiedt wrote:
>> By widget code do you mean your widget template? Because... That is
>> the intended purpose of the widget templates...
>>
>> -Karl Tiedt
>>
>> On Fri, Jul 10, 2015 at 3:11 PM, Deno Vichas
>> <[hidden email] <mailto:[hidden email]>> wrote:
>>
>>     All,
>>
>>     Is there a way to use _TemplateMixin (mostly _stringRepl)and and
>>     dojo/text to load some markup, do some variable substitution to
>>     produce
>>     a dom node?  I'm trying to avoid have lots of little bits of markup in
>>     my widget code.
>>
>>
>>     Thanks,
>>     Deno
>>
>>
>>
>>     --
>>     Dojo Toolkit: http://dojotoolkit.org/
>>     Tutorials: http://dojotoolkit.org/documentation/
>>
>>     [hidden email]
>>     <mailto:[hidden email]>
>>     To unsubscribe, visit:
>>     http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
>>
>>
>>
>>
>

--
Dylan Schiemann
SitePen, Inc.
Dojo workshops in the US, Canada, and Europe:
http://www.sitepen.com/workshops/
http://www.sitepen.com/

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Co-Founder, Dojo Toolkit
CEO, SitePen, Inc.  http://www.sitepen.com/
Reply | Threaded
Open this post in threaded view
|

Re: templates and place holders

Karl Tiedt
In reply to this post by denov
I would say, the answer lies in your last sentence of your paragraph here:

"So I'm wanting a way to keep markup in html and being able to use is to build little bits of the dom for a widget."

If it is for a widget already, it sounds like it should already be a template and would be 100% the way to go, unless you are mincing your words here.

w/o code examples it is rather vague how you mean 'for a widget' and 'template' and how you feel they do not already fit together to solve this.

-Karl Tiedt

On Sat, Jul 11, 2015 at 10:14 AM, Deno Vichas <[hidden email]> wrote:
So in one use case I've been building some forms where I need to display tabular data.   It seems a bit heavy to need to build another widget.  Maybe I'm just being a lazy here..  And I really dislike having any markup at all in my code.  So I'm wanting a way to keep markup in html and being able to use is to build little bits of the dom for a widget.

I think I want something like this -

// template load via dojo/text

Array.forEach(data.ArrayOfThings, function(obj){ domContrust.toDomFromTemplate(template, obj) })


I've start on some code for this.   I'll share once I get something worth while.


- Deno




On 7/10/2015 4:45 PM, Karl Tiedt wrote:
By widget code do you mean your widget template? Because... That is the intended purpose of the widget templates...

-Karl Tiedt

On Fri, Jul 10, 2015 at 3:11 PM, Deno Vichas <[hidden email]> wrote:
All,

Is there a way to use _TemplateMixin (mostly _stringRepl)and and
dojo/text to load some markup, do some variable substitution to produce
a dom node?  I'm trying to avoid have lots of little bits of markup in
my widget code.


Thanks,
Deno



--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest





--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest



--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: templates and place holders

denov
Here's what i'm current playing with.

define([
  "dojo/_base/lang",
  "dojo/_base/array",
  "dojo/dom-construct",
  "dojo/string"
],
function(lang, Array, domConstruct, string){

    return lang.mixin(domConstruct, {

        toDomFromTemplate: function (tmpl, values) {
            if(values){ tmpl = this._stringReplace(tmpl, values); }
            return domConstruct.toDom(tmpl);
        },


        // taken from _TemplatedMixin.js

        _stringReplace: function(tmpl, study){
            var _this = this;
            return string.substitute(tmpl, study, function(value, key){
                if(key.charAt(0) == '!'){ value = lang.getObject(key.substr(1), false, _this); }
                if(typeof value == 'undefined'){ throw new Error('Inline template: '+key); }
                if(value == null){ return ''; }

                return key.charAt(0) == '!' ? value : this._escapeValue('' + value);
            }, this);
        },

        _escapeValue: function(val){
            // Safer substitution, see heading "Attribute values" in
            // http://www.w3.org/TR/REC-html40/appendix/notes.html#h-B.3.2
            // and also https://www.owasp.org/index.php/XSS_%28Cross_Site_Scripting%29_Prevention_Cheat_Sheet#RULE_.231_-_HTML_Escape_Before_Inserting_Untrusted_Data_into_HTML_Element_Content
            return val.replace(/["'<>&]/g, function(val){
                return {
                    "&": "&amp;",
                    "<": "&lt;",
                    ">": "&gt;",
                    "\"": "&quot;",
                    "'": "&#x27;"
                }[val];
            });
        }

    });

});


On 7/11/2015 12:39 PM, Karl Tiedt wrote:
I would say, the answer lies in your last sentence of your paragraph here:

"So I'm wanting a way to keep markup in html and being able to use is to build little bits of the dom for a widget."

If it is for a widget already, it sounds like it should already be a template and would be 100% the way to go, unless you are mincing your words here.

w/o code examples it is rather vague how you mean 'for a widget' and 'template' and how you feel they do not already fit together to solve this.

-Karl Tiedt

On Sat, Jul 11, 2015 at 10:14 AM, Deno Vichas <[hidden email]> wrote:
So in one use case I've been building some forms where I need to display tabular data.   It seems a bit heavy to need to build another widget.  Maybe I'm just being a lazy here..  And I really dislike having any markup at all in my code.  So I'm wanting a way to keep markup in html and being able to use is to build little bits of the dom for a widget.

I think I want something like this -

// template load via dojo/text

Array.forEach(data.ArrayOfThings, function(obj){ domContrust.toDomFromTemplate(template, obj) })


I've start on some code for this.   I'll share once I get something worth while.


- Deno




On 7/10/2015 4:45 PM, Karl Tiedt wrote:
By widget code do you mean your widget template? Because... That is the intended purpose of the widget templates...

-Karl Tiedt

On Fri, Jul 10, 2015 at 3:11 PM, Deno Vichas <[hidden email]> wrote:
All,

Is there a way to use _TemplateMixin (mostly _stringRepl)and and
dojo/text to load some markup, do some variable substitution to produce
a dom node?  I'm trying to avoid have lots of little bits of markup in
my widget code.


Thanks,
Deno



--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest





--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest






--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: templates and place holders

Karl Tiedt
And how is this supposed to be used to build widgets? You keep mention using markup to build widgets (but not markup in your code), yet... this is just moving templating from one file to another...

-Karl Tiedt

On Mon, Jul 13, 2015 at 11:17 PM, Deno Vichas <[hidden email]> wrote:
Here's what i'm current playing with.

define([
  "dojo/_base/lang",
  "dojo/_base/array",
  "dojo/dom-construct",
  "dojo/string"
],
function(lang, Array, domConstruct, string){

    return lang.mixin(domConstruct, {

        toDomFromTemplate: function (tmpl, values) {
            if(values){ tmpl = this._stringReplace(tmpl, values); }
            return domConstruct.toDom(tmpl);
        },


        // taken from _TemplatedMixin.js

        _stringReplace: function(tmpl, study){
            var _this = this;
            return string.substitute(tmpl, study, function(value, key){
                if(key.charAt(0) == '!'){ value = lang.getObject(key.substr(1), false, _this); }
                if(typeof value == 'undefined'){ throw new Error('Inline template: '+key); }
                if(value == null){ return ''; }

                return key.charAt(0) == '!' ? value : this._escapeValue('' + value);
            }, this);
        },

        _escapeValue: function(val){
            // Safer substitution, see heading "Attribute values" in
            // http://www.w3.org/TR/REC-html40/appendix/notes.html#h-B.3.2
            // and also https://www.owasp.org/index.php/XSS_%28Cross_Site_Scripting%29_Prevention_Cheat_Sheet#RULE_.231_-_HTML_Escape_Before_Inserting_Untrusted_Data_into_HTML_Element_Content
            return val.replace(/["'<>&]/g, function(val){
                return {
                    "&": "&amp;",
                    "<": "&lt;",
                    ">": "&gt;",
                    "\"": "&quot;",
                    "'": "&#x27;"
                }[val];
            });
        }

    });

});


On 7/11/2015 12:39 PM, Karl Tiedt wrote:
I would say, the answer lies in your last sentence of your paragraph here:

"So I'm wanting a way to keep markup in html and being able to use is to build little bits of the dom for a widget."

If it is for a widget already, it sounds like it should already be a template and would be 100% the way to go, unless you are mincing your words here.

w/o code examples it is rather vague how you mean 'for a widget' and 'template' and how you feel they do not already fit together to solve this.

-Karl Tiedt

On Sat, Jul 11, 2015 at 10:14 AM, Deno Vichas <[hidden email]> wrote:
So in one use case I've been building some forms where I need to display tabular data.   It seems a bit heavy to need to build another widget.  Maybe I'm just being a lazy here..  And I really dislike having any markup at all in my code.  So I'm wanting a way to keep markup in html and being able to use is to build little bits of the dom for a widget.

I think I want something like this -

// template load via dojo/text

Array.forEach(data.ArrayOfThings, function(obj){ domContrust.toDomFromTemplate(template, obj) })


I've start on some code for this.   I'll share once I get something worth while.


- Deno




On 7/10/2015 4:45 PM, Karl Tiedt wrote:
By widget code do you mean your widget template? Because... That is the intended purpose of the widget templates...

-Karl Tiedt

On Fri, Jul 10, 2015 at 3:11 PM, Deno Vichas <[hidden email]> wrote:
All,

Is there a way to use _TemplateMixin (mostly _stringRepl)and and
dojo/text to load some markup, do some variable substitution to produce
a dom node?  I'm trying to avoid have lots of little bits of markup in
my widget code.


Thanks,
Deno



--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest





--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest






--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest



--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: templates and place holders

denov
It's not for a whole widget.  I'm using it to show things like tabular data or a list of things that need a tiny bit of formatting within a widget.  So I guess it's more of a sub-widget.  Places where I feel that a widget is a bit heavy.

(Sorry for the medical jargon here..) One of the things I'm building right now is a form to show effect measurements for (medical) outcomes.   In this form I have a section for primary studies with 2 rows. One row for automatically added primary studies, and one for manually added.   The data structure is a single list of studies, each one with a flag for auto or manual.  I need to loop through this list display a row of data in the right place.  The template for this is ~10 lines which seems like way to much to put into my widget code.

So I went looking for something to help in the toolkit.  As this seemed like something that others would want to do I was hoping there was somewhere already there.  After some digging and the comments on this thread I realized there wasn't and I need to wrap a little helper.   I'm thinking about adding a placeTemplate(templ, values, refNode, position)  function to what I have so far. 


BTW, why does dom-construct use 'exports' and dom-class doesn't?

- Deno


On 7/14/2015 12:44 AM, Karl Tiedt wrote:
And how is this supposed to be used to build widgets? You keep mention using markup to build widgets (but not markup in your code), yet... this is just moving templating from one file to another...

-Karl Tiedt

On Mon, Jul 13, 2015 at 11:17 PM, Deno Vichas <[hidden email]> wrote:
Here's what i'm current playing with.

define([
  "dojo/_base/lang",
  "dojo/_base/array",
  "dojo/dom-construct",
  "dojo/string"
],
function(lang, Array, domConstruct, string){

    return lang.mixin(domConstruct, {

        toDomFromTemplate: function (tmpl, values) {
            if(values){ tmpl = this._stringReplace(tmpl, values); }
            return domConstruct.toDom(tmpl);
        },


        // taken from _TemplatedMixin.js

        _stringReplace: function(tmpl, study){
            var _this = this;
            return string.substitute(tmpl, study, function(value, key){
                if(key.charAt(0) == '!'){ value = lang.getObject(key.substr(1), false, _this); }
                if(typeof value == 'undefined'){ throw new Error('Inline template: '+key); }
                if(value == null){ return ''; }

                return key.charAt(0) == '!' ? value : this._escapeValue('' + value);
            }, this);
        },

        _escapeValue: function(val){
            // Safer substitution, see heading "Attribute values" in
            // http://www.w3.org/TR/REC-html40/appendix/notes.html#h-B.3.2
            // and also https://www.owasp.org/index.php/XSS_%28Cross_Site_Scripting%29_Prevention_Cheat_Sheet#RULE_.231_-_HTML_Escape_Before_Inserting_Untrusted_Data_into_HTML_Element_Content
            return val.replace(/["'<>&]/g, function(val){
                return {
                    "&": "&amp;",
                    "<": "&lt;",
                    ">": "&gt;",
                    "\"": "&quot;",
                    "'": "&#x27;"
                }[val];
            });
        }

    });

});


On 7/11/2015 12:39 PM, Karl Tiedt wrote:
I would say, the answer lies in your last sentence of your paragraph here:

"So I'm wanting a way to keep markup in html and being able to use is to build little bits of the dom for a widget."

If it is for a widget already, it sounds like it should already be a template and would be 100% the way to go, unless you are mincing your words here.

w/o code examples it is rather vague how you mean 'for a widget' and 'template' and how you feel they do not already fit together to solve this.

-Karl Tiedt

On Sat, Jul 11, 2015 at 10:14 AM, Deno Vichas <[hidden email]> wrote:
So in one use case I've been building some forms where I need to display tabular data.   It seems a bit heavy to need to build another widget.  Maybe I'm just being a lazy here..  And I really dislike having any markup at all in my code.  So I'm wanting a way to keep markup in html and being able to use is to build little bits of the dom for a widget.

I think I want something like this -

// template load via dojo/text

Array.forEach(data.ArrayOfThings, function(obj){ domContrust.toDomFromTemplate(template, obj) })


I've start on some code for this.   I'll share once I get something worth while.


- Deno




On 7/10/2015 4:45 PM, Karl Tiedt wrote:
By widget code do you mean your widget template? Because... That is the intended purpose of the widget templates...

-Karl Tiedt

On Fri, Jul 10, 2015 at 3:11 PM, Deno Vichas <[hidden email]> wrote:
All,

Is there a way to use _TemplateMixin (mostly _stringRepl)and and
dojo/text to load some markup, do some variable substitution to produce
a dom node?  I'm trying to avoid have lots of little bits of markup in
my widget code.


Thanks,
Deno



--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest





--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest






--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest






--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: templates and place holders

dylanks
See comments inline.

on 7/14/15, 10:09 (GMT-07:00) Deno Vichas said the following:
> It's not for a whole widget.  I'm using it to show things like tabular
> data or a list of things that need a tiny bit of formatting within a
> widget.  So I guess it's more of a sub-widget.  Places where I feel that
> a widget is a bit heavy.

_WidgetBase and its dependencies are pretty large when you really just
need a DOM fragment to be inserted. Keep in mind with your approach, any
event handlers should probably be added to the parent of these templates
using delegation, so they can be available as soon as the template is added.

> (Sorry for the medical jargon here..) One of the things I'm building
> right now is a form to show effect measurements for (medical)
> outcomes.   In this form I have a section for primary studies with 2
> rows. One row for automatically added primary studies, and one for
> manually added.   The data structure is a single list of studies, each
> one with a flag for auto or manual.  I need to loop through this list
> display a row of data in the right place.  The template for this is ~10
> lines which seems like way to much to put into my widget code.
>
> So I went looking for something to help in the toolkit.  As this seemed
> like something that others would want to do I was hoping there was
> somewhere already there.  After some digging and the comments on this
> thread I realized there wasn't and I need to wrap a little helper.   I'm
> thinking about adding a /placeTemplate(templ, values, refNode,
> position)/  function to what I have so far.

Or you could just do what create/place do, and add that as an extra set
of parameters. Unless you have real cases for creating all of the
templates at once in a DocumentFragment, and then adding them as a batch
operation.

> BTW, why does dom-construct use 'exports' and dom-class doesn't?

I don't think we had a set standard for whether to use exports or return
{} at the time these modules were created, but they effectively
accomplish the same thing here. Is this blocking some behavior, or just
a question?

exports is generally used when something might modify the module, or
when dealing with possible circular dependencies, though I don't think
that's why dom-construct was written using exports.

> - Deno
>
>
> On 7/14/2015 12:44 AM, Karl Tiedt wrote:
>> And how is this supposed to be used to build widgets? You keep mention
>> using markup to build widgets (but not markup in your code), yet...
>> this is just moving templating from one file to another...
>>
>> -Karl Tiedt
>>
>> On Mon, Jul 13, 2015 at 11:17 PM, Deno Vichas
>> <[hidden email] <mailto:[hidden email]>> wrote:
>>
>>     Here's what i'm current playing with.
>>
>>     define([
>>       "dojo/_base/lang",
>>       "dojo/_base/array",
>>       "dojo/dom-construct",
>>       "dojo/string"
>>     ],
>>     function(lang, Array, domConstruct, string){
>>
>>         return lang.mixin(domConstruct, {
>>
>>             toDomFromTemplate: function (tmpl, values) {
>>                 if(values){ tmpl = this._stringReplace(tmpl, values); }
>>                 return domConstruct.toDom(tmpl);
>>             },
>>
>>
>>             // taken from _TemplatedMixin.js
>>
>>             _stringReplace: function(tmpl, study){
>>                 var _this = this;
>>                 return string.substitute(tmpl, study, function(value, key){
>>                     if(key.charAt(0) == '!'){ value = lang.getObject(key.substr(1), false, _this); }
>>                     if(typeof value == 'undefined'){ throw new Error('Inline template: '+key); }
>>                     if(value == null){ return ''; }
>>
>>                     return key.charAt(0) == '!' ? value : this._escapeValue('' + value);
>>                 }, this);
>>             },
>>
>>             _escapeValue: function(val){
>>                 // Safer substitution, see heading "Attribute values" in
>>                 // http://www.w3.org/TR/REC-html40/appendix/notes.html#h-B.3.2
>>                 // and also https://www.owasp.org/index.php/XSS_%28Cross_Site_Scripting%29_Prevention_Cheat_Sheet#RULE_.231_-_HTML_Escape_Before_Inserting_Untrusted_Data_into_HTML_Element_Content
>>                 return val.replace(/["'<>&]/g, function(val){
>>                     return {
>>                         "&": "&amp;",
>>                         "<": "&lt;",
>>                         ">": "&gt;",
>>                         "\"": "&quot;",
>>                         "'": "&#x27;"
>>                     }[val];
>>                 });
>>             }
>>
>>         });
>>
>>     });
>>
>>
>>
>>     On 7/11/2015 12:39 PM, Karl Tiedt wrote:
>>>     I would say, the answer lies in your last sentence of your
>>>     paragraph here:
>>>
>>>     "So I'm wanting a way to keep markup in html and being able to
>>>     use is to build little bits of the dom for a widget."
>>>
>>>     If it is for a widget already, it sounds like it should already
>>>     be a template and would be 100% the way to go, unless you are
>>>     mincing your words here.
>>>
>>>     w/o code examples it is rather vague how you mean 'for a widget'
>>>     and 'template' and how you feel they do not already fit together
>>>     to solve this.
>>>
>>>     -Karl Tiedt
>>>
>>>     On Sat, Jul 11, 2015 at 10:14 AM, Deno Vichas
>>>     <[hidden email] <mailto:[hidden email]>> wrote:
>>>
>>>         So in one use case I've been building some forms where I need
>>>         to display tabular data.   It seems a bit heavy to need to
>>>         build another widget.  Maybe I'm just being a lazy here..
>>>         And I really dislike having any markup at all in my code.  So
>>>         I'm wanting a way to keep markup in html and being able to
>>>         use is to build little bits of the dom for a widget.
>>>
>>>         I think I want something like this -
>>>
>>>         // template load via dojo/text
>>>
>>>         Array.forEach(data.ArrayOfThings, function(obj){
>>>         domContrust.toDomFromTemplate(template, obj) })
>>>
>>>
>>>         I've start on some code for this.   I'll share once I get
>>>         something worth while.
>>>
>>>
>>>         - Deno
>>>
>>>
>>>
>>>
>>>         On 7/10/2015 4:45 PM, Karl Tiedt wrote:
>>>>         By widget code do you mean your widget template? Because...
>>>>         That is the intended purpose of the widget templates...
>>>>
>>>>         -Karl Tiedt
>>>>
>>>>         On Fri, Jul 10, 2015 at 3:11 PM, Deno Vichas
>>>>         <[hidden email]
>>>>         <mailto:[hidden email]>> wrote:
>>>>
>>>>             All,
>>>>
>>>>             Is there a way to use _TemplateMixin (mostly
>>>>             _stringRepl)and and
>>>>             dojo/text to load some markup, do some variable
>>>>             substitution to produce
>>>>             a dom node?  I'm trying to avoid have lots of little
>>>>             bits of markup in
>>>>             my widget code.
>>>>
>>>>
>>>>             Thanks,
>>>>             Deno
>>>>
>>>>
>>>>
>>>>             --
>>>>             Dojo Toolkit: http://dojotoolkit.org/
>>>>             Tutorials: http://dojotoolkit.org/documentation/
>>>>
>>>>             [hidden email]
>>>>             <mailto:[hidden email]>
>>>>             To unsubscribe, visit:
>>>>             http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>         --
>>>         Dojo Toolkit: http://dojotoolkit.org/
>>>         Tutorials: http://dojotoolkit.org/documentation/
>>>
>>>         [hidden email]
>>>         <mailto:[hidden email]>
>>>         To unsubscribe, visit:
>>>         http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
>>>
>>>
>>>
>>>
>>
>>
>>     --
>>     Dojo Toolkit: http://dojotoolkit.org/
>>     Tutorials: http://dojotoolkit.org/documentation/
>>
>>     [hidden email]
>>     <mailto:[hidden email]>
>>     To unsubscribe, visit:
>>     http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
>>
>>
>>
>>
>

--
Dylan Schiemann
SitePen, Inc.
Dojo workshops in the US, Canada, and Europe:
http://www.sitepen.com/workshops/
http://www.sitepen.com/

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Co-Founder, Dojo Toolkit
CEO, SitePen, Inc.  http://www.sitepen.com/