- Add the link which represents Twitter button into the template:
- Place the JavaScript provided by Twitter to the .js file for the template:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template name='welcomePage'> | |
<a href="https://twitter.com/intent/tweet?screen_name=TemplHub" | |
class="twitter-mention-button" | |
data-related="TemplHub"> | |
Tweet to @TemplHub | |
</a> | |
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Template.welcomePage.rendered = function () { | |
addTwitterWidget(); | |
} | |
function addTwitterWidget() { | |
!function (d, s, id) { | |
var js, fjs = d.getElementsByTagName(s)[0], | |
p = /^http:/.test(d.location) ? 'http' : 'https'; | |
if (!d.getElementById(id)) { | |
js = d.createElement(s); | |
js.id = id; | |
js.src = p + '://platform.twitter.com/widgets.js'; | |
fjs.parentNode.insertBefore(js, fjs); | |
} | |
}(document, 'script', 'twitter-wjs'); | |
} |
I took this code from http://templhub.com application.
No comments:
Post a Comment