{ "metadata": { "name": "", "signature": "sha256:2e8ed3220d238355be3b39f04358c0113d77cb3dbba6d29e28a9fe683b8042d9" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "[Leaflet - a JavaScript library for mobile-friendly maps](http://leafletjs.com/)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "I have a question: can you use requirejs to deal with non-AMD JavaScript files? According to http://stackoverflow.com/a/14603398/7782: maybe. Seems to be affirmed by [Requirement #9: Load any script](http://requirejs.org/docs/requirements.html#9)." ] }, { "cell_type": "code", "collapsed": false, "input": [ "from IPython.display import HTML, display, clear_output\n", "import uuid\n", "\n", "import jinja2\n", "from jinja2 import Template\n", "\n", "from settings import LEAFLET_KEY\n", "\n", "CSS_URL = \"http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.css\"\n", "LEAFLET_JS_URL = \"http://cdn.leafletjs.com/leaflet-0.7.2/leaflet\"\n", "\n", "div_id = 'i' + str(uuid.uuid4())\n", "\n", "JS = u\"\"\"\n", "\n", "\"\"\"\n", "\n", "# demonstrates interference from .rendered_html CSS\n", "\n", "CSS = \"\"\"\n", "\n", "\"\"\"\n", "\n", "HTML_ = \"\"\"\n", "
\n", "\"\"\"\n", "\n", "template = Template(CSS + JS + HTML_)\n", "HTML(template.render(leaflet_js_url=LEAFLET_JS_URL,\n", " css_url = CSS_URL,\n", " leaflet_api_key = LEAFLET_KEY,\n", " lat=37.8717,\n", " long=-122.2728,\n", " zoom=12,\n", " div_id=div_id,\n", " height=200\n", " ))\n", "\n" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "\n", "\n", "\n", "\n", "\n", "" ], "metadata": {}, "output_type": "pyout", "prompt_number": 1, "text": [ "