[Sputnik-list] Adding CSS/Javascript to a node

Jim Whitehead II jnwhiteh at gmail.com
Wed Mar 19 19:56:32 GMT+2 2008


Currently in sputnik-debug I go through a nasty process of cutting out
the <head> section of the page in order to insert some custom CSS or
Javascript.  I was considering implementing functions similar to what
I've just added for the HTML headers:

node:add_css_url(url)
node:add_css_text(text)
node:add_script_url(type, url)
node:add_script_text(type, text)

These would allow you to add custom CSS files and scripts to the
<head> section of a node.  This obviously would only take effect when
node.wrappers.default() is called, but I think that's a reasonable
case.

The _text versions of each would allow you to specify the text of the
script or CSS without needing to ref another file.  Example usage:

node:add_script_url("text/javascript", NICE_URL .. "_jquery.js")
node:add_css_text[[
.cbox {
  width: auto;
  background-color: red;
}]]

Would something like this be accepted?  It's easy enough to code, but
I wanted to check first since it's a bit more controversial.

- Jim



More information about the Sputnik-list mailing list