search

Home  >  Q&A  >  body text

angular.js - How to output curly braces through django template?

It’s a bit of a silly question, and I suddenly realized that I don’t know how to do it. Django wants to output something like "{{}}" for angularjs to use

I tried some escaping methods but to no avail. By the way, because these curly braces are for angularjs, you cannot use html to escape characters, like this:


{{ 内容内容 }}

That’s not possible....

给我你的怀抱给我你的怀抱2774 days ago785

reply all(1)I'll reply

  • 我想大声告诉你

    我想大声告诉你2017-05-15 16:51:42

    Ask and answer your own questions...I think I found the answer

    Escape in this way in django

    openblock {%
    closeblock %}
    openvariable {{
    closevariable }}
    openbrace {
    closebrace }
    opencomment {#
    closecomment #}

    Like here


    {% templatetag openblock %} 内容内容 {% templatetag closeblock %}

    will be output

    {{content content}} This is a django template that does not treat "content content" as a variable

    There is another way to modify the angular separator, which is even cooler!

    var customInterpolationApp = angular.module('customInterpolationApp', []);

    customInterpolationApp.config(function($interpolateProvider) {
    $interpolateProvider.startSymbol('//');
    $interpolateProvider.endSymbol('//');
    });

    reply
    0
  • Cancelreply