0001"""
0002``Tired of regenerating HTML pages from templates? Want more from Web caches?
0003HInclude makes one thing very easy; including other bits of HTML into your Web
0004page, using the browser.``
0005
0006http://www.mnot.net/javascript/hinclude.html
0007"""
0008
0009from webhelpers.util import html_escape
0010from webhelpers.rails.tags import content_tag
0011
0012def include(url, default=''):
0013 """Do a client-side include of ``url``, defaulting to ``default```
0014 >>> include("/foo","hello")
0015 '<hx:include src="/foo">hello</hx:include>'
0016 """
0017
0018 if callable(url):
0019 url = url()
0020 else:
0021 url = html_escape(url)
0022
0023 return content_tag("hx:include", content=default, src=url)