{ "info": { "author": "UNKNOWN", "author_email": "UNKNOWN", "bugtrack_url": null, "classifiers": [ "Programming Language :: Python", "Programming Language :: Python :: Implementation :: CPython" ], "description": "stringexchange\n========================================\n\nno pyramid\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n.. code:: python\n\n from stringexchange import make_exchange, function_call_emitter\n\n exchange = make_exchange(function_call_emitter)\n\n template = \"\"\"f(a, {}, b)\"\"\".format(exchange.subscribe(\"args\"))\n p = exchange.publisher(\"args\")\n\n p.publish(\"x\")\n p.publish(\"y\\n\")\n p.publish(\"z\")\n\n output = exchange.emit(template)\n assert output == \"f(a, x, y, z, b)\"\n\non pyramid\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nfile structure\n\n- onpyramid.py\n- top.html\n\nonpyramid.py\n\n.. code:: python\n\n # -*- coding:utf-8 -*-\n ## onpyramid.py\n from wsgiref.simple_server import make_server\n from pyramid.config import Configurator\n import os.path\n\n\n def top_view(request):\n js = request.string_exchange.publisher(\"js\")\n css = request.string_exchange.publisher(\"css\")\n return {\"css\": css, \"js\": js}\n\n\n if __name__ == '__main__':\n here = os.path.dirname(os.path.abspath(__file__))\n settings = {\"mako.directories\": here,\n \"pyramid.reload_templates\": True}\n config = Configurator(settings=settings)\n\n config.include(\"pyramid_mako\")\n config.include(\"stringexchange\") # !!\n config.add_mako_renderer(\".html\")\n\n config.add_route('top', '/')\n config.add_view(top_view, route_name='top', renderer=\"top.html\")\n\n app = config.make_wsgi_app()\n server = make_server('0.0.0.0', 8080, app)\n server.serve_forever()\n\ntop.html\n\n.. code:: html\n\n ## top.html\n \n
\n ${request.string_exchange.subscribe(\"css\", emit=\"newline\", iterator=\"unique\")}\n \n \n \n \n <% js.publish('') %>\n <% js.publish('') %>\n