Skip to content

Django Template Filter that parse a tweet in plain text and turn it with working Urls

License

Notifications You must be signed in to change notification settings

VincentLoy/tweetparser-django-template-filter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

tweetParser Django Template Filter

this is a port of tweetParser.js to work as a Django template filter

How does it work ?

Once installed, just :

<p>{{ your_tweet|tweetparser }}</p>

Installation

Set Pytter as a dependecie of your project in requirements.txt Or into your virtualenv type :

$ pip install pytter

Take a look at the Django Documentation just create a directory named templatetags into your Django app directory and past tweet_parser.py into it. (don't forget to create an empty init file like in the example below)

your_django_app/
    static/
    templates/
    templatetags/
        __init__.py
        tweet_parser.py
    urls.py
    views.py

then in your template

{% load tweet_parser %}
<!-- some code -->
<p>{{ your_tweet|tweetparser }}</p>
<!-- some code -->

You can change the classes given to each anchor tags

USER_CLASS = 'tweet_user'
URL_CLASS = 'tweet_url'
HASHTAG_CLASS = 'hashtag'

About

Django Template Filter that parse a tweet in plain text and turn it with working Urls

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages