[Dojo-interest] Can't build script if dynamic themes are used?

Jake Conk jake.conk at gmail.com
Mon Nov 13 21:41:13 MST 2006


Actually as a cave man style hack I just did this so it works for now...


switch (theme){

    case "theme1":
        this.templatePath=dojo.uri.moduleUri(...);
        this.templateCssPath=dojo.uri.moduleUri(...);
    break;

    ... etc ...

}


This is not exactly dynamic but it works, I just gotta remember to add a new
case for each theme I add now :\

Regards,
- Jake



On 11/13/06, Jake Conk <jake.conk at gmail.com> wrote:
>
> I tried that and unfortunately that didn't work either. Maybe I just might
> have to not use `intern-strings' when building until a solution gets added
> for this. Is there a place where I can submit this for a request?
>
> On 11/10/06, James Burke <jburke at dojotoolkit.org> wrote:
> >
> > Try not putting in these two lines in the defineWidget properties:
> >
> >         templatePath :
> > dojo.uri.dojoUri("../mycomp/dojo/widget/templates/FloatingPane.html"),
> >         templateCssPath :
> > dojo.uri.dojoUri ("../mycomp/dojo/widget/templates/FloatingPane.css"),
> >
> > Instead, put them as part of an else to your if statement in
> > postMixInProperties, and use the same sort of ["templatePath"] syntax
> > as used in the if. As they are now, they will get converted by the
> > intern-strings build target into templateString and templateCssString.
> > Those variables take precedence over their *Path equivalents, and that
> > could explain why reassigning the *Path variables in
> > postMixInProperties does not have an effect.
> >
> > If that doesn't work, then it is probably the call sequence for widget
> > creation, which I don't know much about. For instance, I don't know
> > when postMixInProperties gets called (or even if that is a normal
> > widget creation step).
> >
> > James
> >
> > On 11/10/06, Jake Conk <jake.conk at gmail.com> wrote:
> > > James,
> > >
> > > Thank you so much for taking the time to help me out. I applied the
> > trick
> > > you gave me and now it builds but I have another problem. Now the
> > problem is
> > > its not loading the templatePath or templateCssPath that I am
> > specifying
> > > when its built but when I use it outside of the build it works
> > properly.
> > >
> > > Here is an example of my widget:
> > >
> > >
> > --------------------------------------------------------------------------------------------------------------------
> > >
> > > dojo.provide("mycomp.widget.FloatingPane ");
> > > dojo.require("dojo.widget.FloatingPane");
> > >
> > >
> > > dojo.widget.defineWidget(
> > >     "mycomp.widget.FloatingPane",
> > >     dojo.widget.FloatingPane,
> > >     {
> > >         // Parameters
> > >         theme: 'dojo', // or macos, macpro
> > >
> > >         templatePath :
> > > dojo.uri.dojoUri("../mycomp/dojo/widget/templates/FloatingPane.html"),
> > >         templateCssPath :
> > > dojo.uri.dojoUri("../mycomp/dojo/widget/templates/FloatingPane.css"),
> > >
> > >         // Methods
> > >         postMixInProperties: function ()
> > >         {
> > >
> > > mycomp.widget.FloatingPane.superclass.postMixInProperties.apply (this,
> > > arguments);
> > >             // Set theme
> > >             var theme= this.theme;
> > >             if (theme!='dojo') {
> > >
> > >                 this["templatePath"] =
> > > dojo.uri.dojoUri ("../mycomp/dojo/widget/templates/" + theme
> > > + "FloatingPane.html");;
> > >                 this["templateCssPath"] =
> > > dojo.uri.dojoUri("../mycomp/dojo/widget/templates/" + theme
> > > + "FloatingPane.css");;
> > >
> > >             }
> > >         }
> > > }
> > >
> > >
> > --------------------------------------------------------------------------------------------------------------------
> >
> > >
> > > The "if statement" is where I need to change the theme dynamically. I
> > did
> > > print some stuff out with dojo.debug() to make sure it got to the if
> > > statement to begin with and it does but the themes aren't being
> > applied.
> > >
> > > I would appreciate any other tricks you have up your sleeve to make
> > this
> > > work.
> > >
> > > Thanks again,
> > > - Jake
> > >
> > >
> > >
> > >
> > > On 11/10/06, James Burke < jburke at dojotoolkit.org> wrote:
> > > >
> > > > On 11/9/06, Jake Conk <jake.conk at gmail.com> wrote:
> > > > > Hello,
> > > > >
> > > > > I have in my widget which extends FloatingPane setting the
> > templatePath
> > > and
> > > > > templateCssPath dynamically by use of a variable like below...
> > > > >
> > > > > ------------------------------
> > > > >
> > > > > this.templatePath = dojo.uri.dojoUri
> > > > > ("../myscripts/dojo/widget/templates/" + theme +
> > > > > "FloatingPane.html");
> > > > >
> > > > > ------------------------------
> > > > >
> > > > > The problem is that when I include that script in the build
> > process for
> > > some
> > > > > reason it fails because it thinks
> > > > > "../myscripts/dojo/widget/templates/" is the full path
> > > to
> > > > > the file.
> > > > >
> > > > > This use to work in 0.3.1 but now doesn't. Does anyone know a fix
> > for
> > > this?
> > > > >
> > > > > Thanks,
> > > > > - Jake
> > > >
> > > > The intern-strings part of the build tries to use that path to
> > inject
> > > > the HTML/CSS into the dojo.js instead of loading it via
> > > > XMLHttpRequest. intern-strings just uses regexps to find
> > templatePath
> > > > and templateCssPath. Since regexps are involved, and it probably
> > would
> > > > not be able to figure out what theme you wanted anyway at the time
> > you
> > > > are building the custom dojo.js, using variables in the paths won't
> > > > work with intern-strings.
> > > >
> > > > You can trick the intern-strings regexps by using the following
> > syntax:
> > > >
> > > > this["templatePath"] =
> > > > dojo.uri.dojoUri("../myscripts/dojo/widget/templates/" +
> > > theme +
> > > > "FloatingPane.html");
> > > >
> > > > That should allow the custom build to complete since intern-strings
> > > > will not try to process the path any more.
> > > >
> > > > James
> > _______________________________________________
> > Dojo FAQ: http://dojo.jot.com/FAQ
> > Dojo Book: http://manual.dojotoolkit.org/DojoDotBook
> > Dojo-interest at dojotoolkit.org
> > http://dojotoolkit.org/mailman/listinfo/dojo-interest
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://dojotoolkit.org/pipermail/dojo-interest/attachments/20061113/d3d56fbb/attachment-0001.html


More information about the Dojo-interest mailing list