upgrade
using $.isFunction and support for empty template (issue #27)