Using these tags in your HTML (XHTML actually) is quite easy. For example, to print to the blog's title, you'd use this:
<data:blog.title/>Notice the / before the >. That's needed because templates are XML so all tags have to be closed. If a data tag has to go inside another tag, the syntax is a little different. For example, to enclose the title in a link to the blog, you'd do this:
<a expr:href="data:blog.url"><data:blog.title/></a>Notice the
expr:
before href
. That tells the template engine that the value of this attribute is an expression to be expanded. I don't know the details, but that's what I've understood from it.So knowing all this (and it took me a while to figure it out because the documentation sucks), my next problem was, how to include in in javascript. In particular, I needed it for the delicious tagging at the bottom of each post. I needed the post title and url to be passed to the delicious badge function. This is the code I needed to use:
Delicious.BlogBadge.writeBadge("delicious-blogbadge-"+Math.random(), "http://url", "title", {});Now I generally put my javascript inside
<![CDATA[ ]]>
tags so that I don't have to worry about escaping quotes and relational operators. However, this also means that any data tags I used would be treated as plain text and ignored. I searched for docs on how to do this, and there was none.I then went to the Edit Template section, and clicked the checkbox that said "Expand Widget Templates" and then searched through the template code for other <script> tags. I found some, and got my answer from there, and this is what my delicious call became:
<script type='text/javascript'> Delicious.BlogBadge.writeBadge( "delicious-blogbadge-"+Math.random(), "<data:post.url/>", "<data:post.title/>", {} ); </script>First, there's no CDATA section. Second, I need to replace the quotes that surround the values passed the function with " and then just use the data tags as usual.
Pretty simple, but it took me a really long time to find any documentation on the subject. Let this blog post serve as documentation for anyone else who needs to do the same.
2 comments :
hmmm...i see i see
its good info, by the way, i'll review your blog next time...
nice to meet you, saloom from bandung blogger Indonesian
Thank you for that, solved my problem perfectly.
Post a Comment