# XHTML + JavaScript problem caused by slug ending with /

**URL:** <https://www.ruby-forum.com/t/xhtml-javascript-problem-caused-by-slug-ending-with/65754>\
**Category:** Radiant CMS\
**Created:** [August 21, 2006, 4:35am UTC](https://www.ruby-forum.com/t/xhtml-javascript-problem-caused-by-slug-ending-with/65754 "2006-08-21T04:35:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![gui\_dos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/e79b87/32.png) [@gui\_dos](https://www.ruby-forum.com/u/gui_dos)\
**Post date:** [August 21, 2006, 4:35am UTC](https://www.ruby-forum.com/t/xhtml-javascript-problem-caused-by-slug-ending-with/65754/1 "2006-08-21T04:35:58Z")

</div>

Hi,

I’m generating some script tags that reference JavaScript in my  
content. The JavaScript is not external but part of the database  
content, and is rendered with a layout that gives it the  
text/javascript mime type.

I cannot get (when using XHTML Transitional) my JavaScript to run  
because the browsers are not fetching the URL constructed by my  
\<r:url/\> tag. Here are the generated script tags:-

I think the browser doesn’t want the URLs to end in a / when in an  
XHTML document. Does anyone know what I can do here?

– G.

---

<div class="post-metadata">

**Author:** ![gui\_dos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/e79b87/32.png) [@gui\_dos](https://www.ruby-forum.com/u/gui_dos)\
**Post date:** [August 21, 2006, 4:42am UTC](https://www.ruby-forum.com/t/xhtml-javascript-problem-caused-by-slug-ending-with/65754/2 "2006-08-21T04:42:00Z")

</div>

I forgot to include the URLs for my generated XHTML in case someone  
would like to take a look at them.

[http://dev.sohne.net/projects/semafox/formats/xhtml-css/](http://dev.sohne.net/projects/semafox/formats/xhtml-css/)  
[http://dev.sohne.net/projects/semafox/formats/xhtml-svg/](http://dev.sohne.net/projects/semafox/formats/xhtml-svg/)

The tags are generated by a snippet containing the below

\<r:find url=“/projects/semafox/styles”\>  
\<r:children:each\>  
  
\</r:children:each\>  
\</r:find\>  
\<r:find url=“/projects/semafox/javascript”\>  
\<r:children:each\>  
  
\</r:children:each\>  
\</r:find\>

It would work if the last \<r:url/\> did not end with a ‘/’, I think.

– G.

---

<div class="post-metadata">

**Author:** ![gui\_dos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/e79b87/32.png) [@gui\_dos](https://www.ruby-forum.com/u/gui_dos)\
**Post date:** [August 21, 2006, 10:00am UTC](https://www.ruby-forum.com/t/xhtml-javascript-problem-caused-by-slug-ending-with/65754/3 "2006-08-21T10:00:36Z")

</div>

I don’t think this is a Radiant problem. Sorry about posting this,  
although any help is still appreciated 🙂

– G.

---

<div class="post-metadata">

**Author:** ![gui\_dos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/e79b87/32.png) [@gui\_dos](https://www.ruby-forum.com/u/gui_dos)\
**Post date:** [August 21, 2006, 5:01pm UTC](https://www.ruby-forum.com/t/xhtml-javascript-problem-caused-by-slug-ending-with/65754/4 "2006-08-21T17:01:36Z")

</div>

I think it has to do with having your Radius tags inside an XHTML tag.  
Correct me if I’m wrong, John, but it won’t parse them inside tags or  
their  
attributes?  
You might be better off just linking to them statically, or writing a  
tag  
definition to do it for you.

Sean C.  
[seancribbs.com](http://seancribbs.com)

---

<div class="post-metadata">

**Author:** ![gui\_dos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/e79b87/32.png) [@gui\_dos](https://www.ruby-forum.com/u/gui_dos)\
**Post date:** [August 21, 2006, 7:10pm UTC](https://www.ruby-forum.com/t/xhtml-javascript-problem-caused-by-slug-ending-with/65754/5 "2006-08-21T19:10:02Z")

</div>

I’ve figured the problem out.

I was loading ‘library’ Javascript and writing glue code for each  
actual page to tailor the library to the content I am generating  
(using JavaScript to generate CSS, SVG, table layout in my DOM).

So after my first two tags, which I verified are working properly, I  
have an inline script element that doesn’t load its JavaScript content  
from an external source. Here is a small test case explaining this.

\<?xml version="1.0" encoding="utf-8"?\>

If you load that from inside the browser, it doesn’t call the alert  
function. However, if you remove the first two lines (XML declaration,  
the CDATA stuff, above and below the hello lines), it works fine.

Put them back in and it stops working. Unless you create new layout  
and assign it a text/xml mime type. So in the end the problem with my  
scripts not being called is that I was serving XHTML as text/html and  
not as text/xml … and as a result, any content inside the CDATA  
section was being ignored (probably it was trying to parse it as a  
tag?).

Thanks for the help 🙂

– G.

---

<div class="post-metadata">

**Author:** ![gui\_dos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/e79b87/32.png) [@gui\_dos](https://www.ruby-forum.com/u/gui_dos)\
**Post date:** [August 21, 2006, 5:15pm UTC](https://www.ruby-forum.com/t/xhtml-javascript-problem-caused-by-slug-ending-with/65754/6 "2006-08-21T17:15:38Z")

</div>

Sean C. wrote:

> I think it has to do with having your Radius tags inside an XHTML tag.  
> Correct me if I’m wrong, John, but it won’t parse them inside tags or their  
> attributes?

It will parse tags inside of HTML attributes. What it can’t parse is  
tags inside of Radius tag attributes.

So this works fine:

My Link

but this does not:

\<r:link title=“\<r:title /\>” /\>

–  
John L.  
[http://wiseheartdesign.com](http://wiseheartdesign.com)
