3

Would someone be so kind as to explain what this data object is (if it is an object) and if there is any documentation on it.

I was adding social sharing buttons to an app and decided I wanted to put a share to Blogger button on there, just for the fun of it. I could not find a page that had an official 'share to Blogger' button, like Facebook has an official 'like' button, or Twitter, a 'tweet' button. What I did find was this post on adding sharing buttons to a blog with the attached text file. I noticed that most, if not all of the html tags use the 'data:post.url' and 'data:post.title' to dynamically grab the URL and title of the blog post.

Example:

<a expr:href='&quot;http://reddit.com/submit?url=&quot; + data:post.url + &quot;&amp;title=&quot; + data:post.title' target='_blank' title='Share On Reddit !'><img alt='Share On Reddit !' src='http://1.bp.blogspot.com/_YUvD9j84Cik/TBvM2-Sw3ZI/AAAAAAAAAHk/QKghefISkNc/reddit.gif' style='width:16px; height:16px; padding:0; border:0; vertical-align:middle;'/></a> 

<a expr:href='&quot;http://www.blogger.com/blog_this.pyra?t&quot; + &quot;&amp;u=&quot; + data:post.url + &quot;&amp;n=&quot; + data:post.title + &quot;&amp;pli=&quot; + 1' target='_blank' title='Post To Blogger !'><img alt='Post To Blogger !' src='http://1.bp.blogspot.com/_YUvD9j84Cik/TBvMqnnrVtI/AAAAAAAAAG8/O65EnRFSHFk/blogger.gif' style='width:16px; height:16px; padding:0; border:0; vertical-align:middle;'/></a> 

<a expr:href='&quot;http://www.friendfeed.com/share?link=&quot; + data:post.url + &quot;&amp;title=&quot; + data:post.title' target='_blank' title='Share On Friend Feed !'><img alt='Share On Friend Feed !' src='http://1.bp.blogspot.com/_YUvD9j84Cik/TBvMxcy7H8I/AAAAAAAAAHU/UfNllYiyznA/friendfeed.gif' style='width:16px; height:16px; padding:0; border:0; vertical-align:middle;'/></a> 

When looking into this on stackOverflow, I've found that it is suggested for people using social comments and share buttons who are having issues with sharing their URLs, though, it is notable that none of the answers have been marked correct.

Is this something that is strictly limited to the Blogger/Blogspot platforms, or is it something that is handled by the browser? I haven't been able to find anything in the DOM referring to data or post. I'd be interested to know how this can be used more broadly and if it should be used at all.

4

2 回答 2

3

In this case, data: is a namespace that scopes the data available from Blogger that can be included in a template. The authoritative list of what's availabe is here.

It is Blogger-centric.

The other namespaces are b: which deals with layout and control flow, and expr: which keys the engine into the fact that the tags involve data from Blogger (as you have above).

A good tutorial is here.

于 2013-10-08T19:38:10.037 回答
2

在 Blogger 模板 data:post.url中返回当前页面的 url,data:post.title返回帖子的标题。这些术语是特定于 blogger API 的,因此这些代码可以在 blogger 模板中使用,而在其他任何地方都不起作用。

例如, <a expr:href='data:post.url'>在 blogger 模板中输入,将给出输出<a href="http://urlofthepage">

因此,如果我转到http://meow.blogspot.com/2011/03/ab.html将出现在源代码中的代码将是 <a href="http://meow.blogspot.com/2011/03/ab.html">

于 2013-10-08T19:39:20.617 回答