[3] | 1 | """ |
---|
| 2 | ``Tired of regenerating HTML pages from templates? Want more from Web caches? |
---|
| 3 | HInclude makes one thing very easy; including other bits of HTML into your Web |
---|
| 4 | page, using the browser.`` |
---|
| 5 | |
---|
| 6 | http://www.mnot.net/javascript/hinclude.html |
---|
| 7 | """ |
---|
| 8 | |
---|
| 9 | from webhelpers.util import html_escape |
---|
| 10 | from webhelpers.rails.tags import content_tag |
---|
| 11 | |
---|
| 12 | def include(url, default=''): |
---|
| 13 | """Do a client-side include of ``url``, defaulting to ``default``` |
---|
| 14 | >>> hinclude.include("/foo","hello") |
---|
| 15 | '<hx:include src="/foo">hello</hx:include>' |
---|
| 16 | """ |
---|
| 17 | |
---|
| 18 | if callable(url): |
---|
| 19 | url = url() |
---|
| 20 | else: |
---|
| 21 | url = html_escape(url) |
---|
| 22 | |
---|
| 23 | return content_tag("hx:include", content=default, src=url) |
---|