javascript - How to use Hogan in django template -


is possible include following in django html file?

<!-- hit template --> <script type="text/template" id="hit-template">   <div class="hit media">     <a class="pull-left" href="{{ url }}">       <img class="media-object" src="{{ image }}" alt="{{ name }}">     </a>     <div class="media-body">       <h3 class="hit_price pull-right text-right text-danger">         ${{ saleprice }}       </h3>       <h4 class="hit_name">{{{ _highlightresult.name.value }}}</h4>       <p>         {{{ _highlightresult.shortdescription.value }}}       </p>       <ul class="hit_tags list-inline">         {{#_highlightresult.manufacturer}}<li>{{{ _highlightresult.manufacturer.value }}}</li>{{/_highlightresult.manufacturer}}         {{#_highlightresult.category}}<li>{{{ _highlightresult.category.value }}}</li>{{/_highlightresult.category}}         {{#type}}<li>{{{ type }}}</li>{{/type}}       </ul>     </div>   </div> </script> 

when include django error, django templating engine seems trying parse first.

if you're running django >= 1.5, try verbatim template tag.

[edit]

on earlier versions of django, should able replicate template tag functionality following:

""" https://gist.github.com/1313862 """  django import template  register = template.library()   class verbatimnode(template.node):      def __init__(self, text):         self.text = text      def render(self, context):         return self.text   @register.tag def verbatim(parser, token):     text = []     while 1:         token = parser.tokens.pop(0)         if token.contents == 'endverbatim':             break         if token.token_type == template.token_var:             text.append('{{')         elif token.token_type == template.token_block:             text.append('{%')         text.append(token.contents)         if token.token_type == template.token_var:             text.append('}}')         elif token.token_type == template.token_block:             text.append('%}')     return verbatimnode(''.join(text)) 

Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -