This package provides WordPress shortcode support for Django templates. It is based on code by Mark Steadman.
Support for different shortcodes are generated by parsers. The package currently includes a parser for YouTube videos. Additional parsers can be submitted for inclusion at the package's issue tracker.
Use pip install django-shortcodes
or clone the Git
repository.
{% load shortcodes_filters %} {{ text|shortcodes|safe }}
Spotify
Hey there, check out this rad song on Spotify: [spotify uri=spotify:track:41eiwHEX8iegmqmS2cf7oX]
Available parameters:
uri
(required): The Spotify URI for a track, album, playlist, etc., that you'd like to embed. This can be found in the Spotify app with "Copy Spotify URI" buttons.width
: The width of the embed. If not set, 480 is the default.height
: The height of the embed. If not set, 480 is the default.theme
: Color theme of the embed, either 'black' or 'white'view
: View styles of the embed, either 'list', 'coverart'.
Parameters are implemented as documented here: https://developer.spotify.com/technologies/widgets/spotify-play-button/
Soundcloud
Oh hi, check out this rad song on Soundcloud: [soundcloud url=https://soundcloud.com/epitaph-records/the-menzingers-thick-as-thieves]
Available parameters:
url
(required): The URL for the Soundcloud track or collection that you'd like to embed.width
: The width of the embed. If not set, 480 is the default.height
: The height of the embed. If not set, 166 is the default.color
: Optionally specify a button color in hex format without the # character, e.g. c0ff33.
SHORTCODES_VIMEO_HEIGHT
: Default height for Vimeo videos.SHORTCODES_VIMEO_WIDTH
: Default width for Vimeo videos.
SHORTCODES_YOUTUBE_HEIGHT
: Default height for YouTube videos.SHORTCODES_YOUTUBE_WIDTH
: Default width for YouTube videos.
SHORTCODES_SPOTIFY_WIDTH
: Default width for Spotify embeds, can be a number or a percentage, e.g. 80%SHORTCODES_SPOTIFY_HEIGHT
: Default height for Spotify embeds, can be a number or a percentage, e.g. 80%
SHORTCODES_SOUNDCLOUD_HEIGHT
: Default height for Soundcloud player embeds.SHORTCODES_SOUNDCLOUD_WIDTH
: Default width for Soundcloud player embeds.