You're probably missing an empty __init__.py file: https://docs.djangoproject.com/en/1.8/howto/custom-template-tags/#code-layout
On Thu, Jul 16, 2015 at 12:00 PM, Brandon Keith Biggs < [email protected]> wrote: > Hello, > I can't get this method to work. Here is what I have: > my_app/script_module.py > from mezzanine import template > register = template.Library() > > @register.as_tag > def test_text(): > return "Hello world" > > > my_theme/templates/index.html > {% extends "base.html" %} > {% load i18n %} > {% test_text %} > > I get the error: > TemplateSyntaxError at / > Invalid block tag: 'test_text' > > I then try adding in index.html: > > {% extends "base.html" %} > {% load i18n %} > {% load my_app %} > {% test_text %} > > But then get: > TemplateSyntaxError at / > 'my_app' is not a valid tag library: > > So then when I put > script_module.py > into > my_app/templatetags/my_script.py > I still get the same error. > thanks, > > Brandon Keith Biggs <http://www.brandonkeithbiggs.com/> > On 7/16/2015 1:18 AM, Eduardo Rivas wrote: > > That should work without issue, though I generally like to bundle all the > "as" tags on top of the block. > > {% block main %} > {% get_sitewide_content as sitewide %} > <h1>my text</h1> > {{ sitewide.foobar }} > {% endblock %} > > Also, be careful with the blocktrans tag, you need to explicitly bind any > variable you want to use inside them. You should also avoid including HTML > tags inside them to prevent poluting the gettext catalog with markup > https://docs.djangoproject.com/en/1.7/topics/i18n/translation/#blocktrans-template-tag > . > > > -- > You received this message because you are subscribed to the Google Groups > "Mezzanine Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- Stephen McDonald http://jupo.org -- You received this message because you are subscribed to the Google Groups "Mezzanine Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
