Home > database >  Django ignore TemplateSyntaxError. Vue Syntax
Django ignore TemplateSyntaxError. Vue Syntax

Time:04-12

I'm building a pwa on top of django.

In the pwa.html I use valid vue syntax:

{{ counter() }}

or

 {{ el| removehtml() | truncate(40) }}

Works flawless in a non Django project.

I get an TemplateSyntaxError on runserver, how can I ignore this, cause this is valid for vue syntax.

CodePudding user response:

I found 2 solutions:

either in vue with delimiters:

el: '#app',
  delimiters: ['[[', ']]'],
  data: {
    message: ...
  }

...

than in template [[ vuefunc() ]] instead of default {{ vuefunct() }}

or with django verbatim

{% verbatim %}

    {{ vuefunct() }}
      
{% endverbatim %}

CodePudding user response:

Please note that Django does not use Jinja. It has its own template syntax, explained here in the documentation.

If you have any exposure to other text-based template languages, such as Smarty or Jinja2, you should feel right at home with Django’s templates.

The syntax may look like Jinja, but the functions could be different.

  • Related