Search code examples
asp.net-mvcrazorbootstrap-typeahead

Twitter Typeahead templating with razor engine


I need to use Twitter Typeahead's template feature so that I can display a long,styled suggestions (example: suburbs with postcodes and postcodes highlighted in blue).

According to twitter docs (https://github.com/twitter/typeahead.js#readme), we need to provide the template with an engine that supports following API calls,

var compiledTemplate = ENGINE.compile(template);

var html = compiledTemplate.render(context);

Can/Have we extend the razor view engine to have these methods?

Otherwise, I need to bring-on something like Hogan, purely to perform templating in typeahead JS


Solution

  • Okay, I ended up using the Twitter's Hogan. It was only a few KBs.