This may be easier to maintain if we use library with templating. E.g. if we use underscore.js templates the code will be cleaner, and then we can use _filter to do searches.