2

I want to include a JS snippet in a Wiki page.

I read this post:
Referencing javascript from trac wiki
and set rendering_unsafe_content = true under [wiki] and restarted the server.
I then placed this in a new/empty wiki page:

{{{
#!html
<script type="text/javascript" >
   alert("Test1");
</script>
}}}

but, no alert when the page loads.
I've also tried this:

{{{
#!html
<script type="text/javascript">
$(document).ready(function() {
   alert("Test2");
});
</script>
}}}

but that also doesn't work.

In both instances, the JS isn't even included in the rendered page (as determined by inspecting the content).

This would seem to be pretty straightforward, so I'm puzzled that its not working... can anyone tell me what I'm missing?

Thanks!
-Dave

Community
  • 1
  • 1
dlchambers
  • 3,511
  • 3
  • 29
  • 34
  • 2
    Your two examples result in a dialog box for me on Trac `1.0.2dev`. If that's not a typo in your post, then it's a typo in your _trac.ini_ file. The option is `[wiki] render_unsafe_content` (not `rendering_unsafe_content`). See [documentation](http://trac.edgewall.org/wiki/TracIni#wiki-section) for confirmation. – RjOllos Dec 26 '13 at 08:24

1 Answers1

3

@RjOlios answered it: I had a typo in the trac.ini. Should be "render_unsafe_content" not "rendering_unsafe_content", and correcting that typo makes JS work. Many thanks!

Also note that Trac seems to require a blank line before the line and an additional blank line after the line. Without these blank lines I find that the JS is not executed but rather rendered as text on the page.

dlchambers
  • 3,511
  • 3
  • 29
  • 34