Reputation: 8524
I want to use dojo doxox/dtl in AMD, OUTSIDE OF A WIDGET!
Currently (2012-02-10) the documentation is not updated to dojo 1.7 AMD (http://dojotoolkit.org/reference-guide/dojox/dtl.html).
In the old documentation the non-AMD example is:
dojo.require("dojox.dtl");
dojo.require("dojox.dtl.Context");
var template = new dojox.dtl.Template("Hello {{ place }}!");
var context = new dojox.dtl.Context({ place: "World" });
console.debug(template.render(context)); // Hello World!
To produce the same output with the new Dojo 1.7 framework, my solution would be to subclass "dojox/dtl/_Templated" and in the constructor of the new class set the template value to the attribute "templateString".
My question is:
Can anybody help me doing dtl templates outside of a widget without subclassing "dojox/dtl/_Templated"?
Thanks alot in advance
Wolfgang
Upvotes: 3
Views: 1025
Reputation: 8524
I found the solution:
define(["dojox/dtl/_base", "dojox/dtl/Context"], function (dtl, Context) {
var compiledTemplate, templateObj, contextObj;
templateObj = new dtl.Template ("Hello {{ place }}!");
contextObj = new Context({ place: "World" });
compiledTemplate = templateObj.render(contextObj);
...
Upvotes: 4