Skip to content

Instantly share code, notes, and snippets.

@TastyToast
Forked from andershaig/tweet.liquid
Created May 22, 2012 18:41
Show Gist options
  • Save TastyToast/2770850 to your computer and use it in GitHub Desktop.
Save TastyToast/2770850 to your computer and use it in GitHub Desktop.
Twitter Intents with Rawtext
<button id="tweet_button">Click to Tweet</button>
<script type="text/javascript">
{% plugin rawtext tweet_url %}
{% plugin rawtext tweet_text %}
{% plugin rawtext tweet_hashtags %}
var params = {};
{% if tweet_url %}
params.url: '{{ tweet_url | escape }}';
{% endif %}
{% if tweet_text %}
params.text: '{{ tweet_text | escape }}';
{% endif %}
{% if tweet_hashtags %}
params.hashtags: '{{ tweet_hashtags | escape }}';
{% endif %}
var intent_url = 'https://twitter.com/intent/tweet?' + $.param(params);
$('#tweet_button').click( function (e) {
e.preventDefault();
window.open(intent_url, 'tweet_intent');
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment