[OpenAjaxIDE] Should macro substitution work on<require>JavaScript files?

Jon Ferraiolo jferrai at us.ibm.com
Tue Aug 5 12:54:37 PDT 2008


See some thoughts below.

ide-bounces at openajax.org wrote on 08/05/2008 11:19:55 AM:

> But what if the developer needs to configure/initialize something with
> data related to a specific instance before something is included? How
> would someone set something up like this?
>
> <script type="text/javascript">
>
> var GalleryConfiguration = {
>    autoStart: true,
>    selector: "#main .slideshow"
> };
>
> </script>
>
> <script type="text/javascript" src="gallery.js"></script>
>
>
> Where the selector was something the developer expected the user to
> provide? Based on current location attribute values, it seems like the
> assumption for <javascript> is that it will be inserted inside the
> <body>. What mechanism does a developer have to insert a templated piece
> of code into the head?
>
> If you say that we can extend the <javascript> "location" attribute to
> insert into the head, how do we say that we need it to go *before* a
> specific <require> includeRef?

We need to talk about this. There are two types of developers here, the
widget developer (who creates the widget metadata file) and the application
developer who creates an application (e.g., using Dreamweaver). We could
add a <javascript location="atStart"> mechanism, but that's only useful for
the widget developer. The application developer should look upon the widget
metadata file as an opaque thing.

>
> Other related questions I was going to bring up:
>
>
> - Is the expectation that the content of a <javascript> tag be just the
> JS code? That is there should be know <script>/</script> wrapper tags
> around the code inside the <javascript> tag.

The expectation is that the contents is JS code and that the tool will add
<script>/</script> wrapper tags. That's what we have done in the reference
implementation. But the spec should say this more clearly.

>
> - I just wanted to confirm that <![CDATA[]]> is only needed for most
> tags if special chars are included, right? So if I have some
> <javascript> code and it never uses '<', '>', I don't need to wrap it
> with <![CDATA[]]> right?

That's been my assumption for <content>, <javascript> and <require>. You
only need to use <![[CDATA[]]> if your content contains something that will
cause problems.

>
> - <preload> and <postload> code ... can this code contain macros? (You
> asked this one already.)

I would say no to <require>, <preload> and <postload>.

>
> - <postload> code ... does this mean insert the code immediately after
> the <script> or <link> tag? What happens if the asset is an image or
> other non CSS/JS asset? Some browsers like Safari load CSS async.

<postload> cames from jMaki, which has a similar mechanism and only uses it
for JS. My suggestion is that <postload> only be allowed for
type="javascript" and that the only promise we make to developers is that
the <postload> logic is inserted into the DOM after the primary JS content
referenced by the parent <require> tag.

Jon

>
> --== Kin ==--
>
> -----Original Message-----
> From: ide-bounces at openajax.org [mailto:ide-bounces at openajax.org] On
> Behalf Of Lori Hylan-Cho
> Sent: Tuesday, August 05, 2008 10:27 AM
> To: Jon Ferraiolo; ide at openajax.org
> Subject: Re: [OpenAjaxIDE] Should macro substitution work
> on<require>JavaScript files?
>
> That's my opinion, too. Localizable/substitutable properties can be
> extracted into a single group of js variables and included as a
> <javascript> block. (In fact, that would make things oh so much easier
> for tools in general. :-P)
>
> > -----Original Message-----
> > From: ide-bounces at openajax.org
> > [mailto:ide-bounces at openajax.org] On Behalf Of Jon Ferraiolo
> > Sent: Tuesday, August 05, 2008 1:21 PM
> > To: ide at openajax.org
> > Subject: [OpenAjaxIDE] Should macro substitution work on
> > <require>JavaScript files?
> >
> > Right now, we have decided that macro substitution:
> >
> > * property substitution such as @@foo@@
> > * localization substitution such as %%bar%%
> > * Gadget-related substitution such as __GID__
> >
> > applies to the following elements: <content>, <javascript>,
> > <description>, <title>, <remarks>, <example>, <license>,
> > <author>, <aboutMe> and <quote>
> >
> > The question for today is question macro substitution should
> > also occur on <require> content. One significant use case is
> > <require type="javascript">, where the JavaScript might
> > contain __GID__ strings.
> >
> > My guess is that we should *NOT* do macro substitution on
> > <require> and tell developers that if they need to have
> > JavaScript that uses __GID__ or localized content or
> > whatever, they should use the <javascript> element instead of
> > the <require> element.
> >
> > Jon
> >
> >
> > ============ EARLIER EMAIL ================
> >
> > Javier responds to Jon:
> > --------------------
> > I had always assumed that the variable substitution only
> > worked on the content inside the spec XML file itself. From
> > what I can tell, this is how Google Gadgets work.
> >
> > However, I can see how this would be a valuable feature,
> > especially for localization bundles. Bring this up in the
> > meeting today, and see what everyone agrees on. Either way,
> > whatever the spec says we'll implement...
> > --------------------
> >
> > Jon asks:
> > --------------------
> > I noticed that if I use __GID__ within some JavaScript inside
> > of a <content> element, macro substitution works, but if I
> > take the same JavaScript and put it into a separate JS file
> > that is loaded via <require type="javascript" src="..."/>,
> > the macro substitution does not seem to occur. Does this
> > sound right? I just wanted to see what you thought. There is
> > always the <javascript src="..."/> option, which (I assume)
> > would trigger macro substitution. (<javascript src=> is not
> > yet implemented in the refimpl)
> >
> > Whatever, the spec needs to be clear on all of this.
> > --------------------
> >
> >
> >
>
> _______________________________________________
> IDE mailing list
> IDE at openajax.org
> http://openajax.org/mailman/listinfo/ide
>
> _______________________________________________
> IDE mailing list
> IDE at openajax.org
> http://openajax.org/mailman/listinfo/ide
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://openajax.org/pipermail/ide/attachments/20080805/dad96cfc/attachment-0001.html 


More information about the IDE mailing list