使用 {% verbatim %}
例如底下的字串 '<div><strong>{{value}}</strong> – {{year}}</div>' 中的 {{value}}, {{year}}你不想 django template解譯
你可以:
{% verbatim %}
$('#search_group #search_input').typeahead({
hint: true,
highlight: true,
minLength: 1,
},
{
name: 'myquery',
displayKey: 'value',
source: objlist.ttAdapter(),
templates: {
empty: [
'<div class="empty-message">',
'unable to find any Best Picture winners that match the current query',
'</div>'
].join('\n'),
suggestion: Handlebars.compile('<div><strong>{{value}}</strong> – {{year}}</div>')
}
}
)
.on('typeahead:opened', function(){
//$('#search_group .tt-menu').css('width',$(this).width() + 'px');
$('#search_group #search_input').typeahead('val', $("#search_group #search_input").val());
})
{% endverbatim %}
沒有留言:
張貼留言