-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
snippet templatetag not usable outside django-cms #491
Comments
this is possible now! |
ojii, would you care to elaborate on how this is possible? I can't find any such tag... |
"this is possible now!" Please elaborate. The plugins/snippet code doesn't seem to have any template tags. |
well, make it! it should be easy enough, as long as you have a way of identifying snippets |
As a quick proof of concept: from cms.plugins.snippet.models import Snippet
from cms.plugins.snippet.cms_plugins import SnippetPlugin
from django import template
register = template.Library()
@register.simple_tag
def show_snippet(name):
try:
return SnippetPlugin().render(
{},
type('obj', (object,), {'snippet' : Snippet.objects.get(name = name)}),
None
)['content']
except Snippet.DoesNotExist:
return "" |
This issue was closed.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
I'm developing a site with a mixture of django-cms and non-django-cms pages. The snippets plugin would be quite useful for sharing snippets between these, except there seems to be no template tag that I can import in order to use it easily in a non-django-cms template. It would be very nice if this were easy (or possible) to do.
The text was updated successfully, but these errors were encountered: