Thursday, August 16th, 2007p>In July, Brad Neuberg and a group of talented hackers released Purple Include, a library that does transclusions.
Now there is a new version which is a major refactoring that simplifies working with the library and now works across all major browsers.
Brad tells us more:
What the heck does that mean?
It means that you can include and display fragments of one HTML page in another without copying and pasting any content. For example, you could quote the second paragraph from another person’s blog entry by embedding something like:
- <div href="http://foo.com/bar.html#xpath(/p)"></div>
in your blog page. The expression following the explanation point in the URL is an XPath expression.
If the page you want to transclude has a fragment identifier or a purple number, you can transclude that directly:
- <div href="http://foo.com/purple.html#nid32 "></div>
In fact, all you have to do is add an ‘href’ attribute to any of the following types of HTML tags in order to have that URL transcluded right into the page when the page loads:
- <p href="http://foobar.com#nid32"></p>
- </blockquote><blockquote href=" http://foobar.com#xpath(/p)"></blockquote>
- <div href="includeme.html#foobar"></div>
- <span href="../../relativefile.html#foobar"></span>
- <q href="http://foobar.com#foobar"></q>
This is all beta stuff, so as usual, if you see bugs, tell me — or even better, fix it ;)
RELEASE NOTES for August 15th, 2007 Purple Include 1.9
This is a pretty radical refactoring of the Purple Include code. The big highlights in this version:
* Now works cross-browser: Internet Explorer, Firefox, and Safari (Opera should work but has not been tested)
* We no longer have an
tag; instead, you can simply add an ‘href’ attribute to many different HTML types and have that type transclude it’s contents:
- <p href="http://codinginparadise.org/paperairplane#xpath(//[@id='table_of_contents'] ")</p>
This works for the following tags: P, BLOCKQUOTE, Q, PRE, DIV, SPAN
* The client-side script has gotten vastly smaller and simpler — the script is now only about 9K.
* We now use the notation #xpath(//p) around an XPath expression rather than using an exclamation point, such as #xpath!//p. This is in keeping with the pseudo-standard that has developed around this practice, such as #xpointer() — it also opens up the possibility of chaining together expressions in the future, such as #xpath(//expression1)xpath(//expression2), which would return the results of both expressions.
15 Comments »