def pjaxify_template_path(template_path, container=None):
    """
    Take a template path and optionally a container, and return the path with
    "-pjax" and (if container is not None) "=<container>" inserted before the
    file extension. For example:

    >>> pjaxify_template_path('templates/product.html', None)
    'templates/product-pjax.html'

    >>> pjaxify_template_path('templates/product.html', 'details')
    'templates/product-pjax=details.html'
    """
    try:
        parts = template_path.rsplit('.', 1)
    except AttributeError:
        raise ValueError('template_path must be a string type')
    pjax_identifier = '='.join(filter(None, ('pjax', container)))
    return '.'.join(['%s-%s' % (parts[0], pjax_identifier)] + parts[1:])
