Package: breakdown
DescriptionBreakdown is a lightweight python webserver that parses jinja2 templates.  It’s intended to be used by designers for doing rapid prototyping.Basic UsageBreakdown needs atemplatesdirectory and astaticdirectory to serve from.  If your working directory contains these, you can simply run breakdown with no arguments:$ breakdownOr, you can specify the path to a directory containingtemplatesandstatic:$ breakdown /path/to/projectBreakdown will also work with a django project structure.  If the project path contains anappsdirectory, breakdown will automatically detect this and combine thestaticandtemplatesdirectories for each django app.  You’ll also get a listing of the directories it found.  Here’s the output of running breakdown on a django project with two apps: ‘mainsite’ and ‘blog’:$ breakdown ~/django/myproject
Serving templates from:
  /Users/josh/django/myproject/apps/blog/templates
  /Users/josh/django/myproject/apps/mainsite/templates

Serving static data from:
  /Users/josh/django/myproject/apps/blog/static
  /Users/josh/django/myproject/apps/mainsite/staticTemplate Context ObjectsYou can define values for template variables by supplying a json dictionary for each page.When loading a template, breakdown will attempt to load a json dictionary of the same name from the context directory (contextby default) and add it to the page context. For example, when loadingblog/article_detail.htmlbreakdown will look for<projectroot>/context/blog/article_detail.json.For all pages, breakdown also attempts to load<projectroot>/context/base.json.  Any values defined here will be available on all pages, and will be overridden by any of the same name defined in individual page context objects.For example, if we definebase.jsonlike this:{
 "request": {
    "user": {
         "name":"Austin",
         "member": "Member #4812"
     }
 },
 "object": {
    "id": 555,
    "title": "Excellent Blog Post"
 }
}thenrequestandobjectbecome available to all templates, and{{request.user.name}}yieldsAustin.You can specify a function by adding a key with trailing parentheses:{
 "request": {
    "user": {
         "name":"Austin",
         "is_authenticated()": true,
         "birth_year()": 1982,
         "middle_name()": "David",
         "member": "Member #4812"
     }
 }
}The trailing parentheses are removed, and now{{request.user.is_authenticated()}}returnsTrue.  Functions defined in this way ignore any arguments and return the value specified in the json dictionary.{{request.user.is_authenticated(arg1, arg2,arg3)}}also returnsTrue. However, these functions cannot be used without parentheses and{{request.user.is_authenticated}}prints something likeat 0x101f32f50>.If you define a__unicode__or__unicode__()key, its value will be used when referencing its enclosing object directly.  With a context object such as either:{
  "request": {
    "user": {
         "name":"Austin",
         "__unicode__": "User named Austin"
     }
 }
}or:{
  "request": {
    "user": {
         "name":"Austin",
         "__unicode__()": "User named Austin"
     }
 }
}referencing{{request.user}}will yieldUser named Austin.Breakdown does not support full context object inheritance, but top-level values defined for individual pages override those defined inbase.json.  If you define<projectroot>/context/blog/article_detail.jsonlike this:{
  "blog": {
    "title": "Skiing Blog"
  },
  "request": {
    "user": {
      "name": "Josh"
    }
  }
}then in/blog/article_detail.htmla reference to{{request.user.name}}will printJosh,{{request.user.birth_year}}is blank, and{{request.user}}yields{u'name': u'Josh'}.Viewing TemplatesOnce breakdown is running, it will print the local URL the webserver is listening on:Server running at http://127.0.0.1:5000 ...You can now view templates in your browser by navigating tohttp://127.0.0.1:5000.  However, you won’t see anything here unless one of your template directories contains a file namedindex.html.  The URL of any template (besidesindex.html) will be identical to its filename, with all relative paths preserved.  Below is an example of template filenames and their corresponding URL on the local server:TemplateURLindex.htmlhttp://127.0.0.1:5000/article.htmlhttp://127.0.0.1:5000/articleblog/index.htmlhttp://127.0.0.1:5000/blogblog/post.htmlhttp://127.0.0.1:5000/blog/postNote: The server will accept template URLs with or without .html appended to themAdditional FeaturesTemplate tagsFor convenience, A few template functions have been added to thejinja2 template API:{{ greeking() }}Generates a block of randomized lorem ipsum text marked-up with various HTML elements:<em>,<strong>,<code>,<a>,<ol>, and<ul>.{{ image(width, height) }}If you havePILinstalled, you can use this function to generate an<img>tag with a sample image of the specified size (without PIL, the width/height are ignored and you get a large sample image){{ url(*args, **kwargs) }}Ignores all arguments and returns'#'.CleverCSSBreakdown also supports automaticCleverCSSparsing.  If the filefoo.cssis requested and not found, breakdown will then look for a matchingfoo.clevercssand compile it to vanilla css on the fly.Export modeBreakdown can run in an alternateexportmode which dumps all of the rendered templates to a directory that you specify.  It also collects all of your static files (similar to djangoscollectstaticcommand) to astatic/directory.  This mode can be enabled with-eand a path to export to; e.g.:breakdown-eoutputNOTE: If you want to be able to browse the exported content from the file system directly, you should make sure that your links to other templates end with ‘.html’AdvancedCommand line options:-h,--helpshow this help message and exit-pPORT,--port=PORTrun server on an alternate port (default is 5000)-m,--mediatreat MEDIA_URL as STATIC_URL in templates-s,--static-urloverride STATIC_URL (default is /static/)-v,--versiondisplay the version number and exit-cDIR,--context_dir_name=DIRset the directory name for context object files (default iscontext)-eDIR,--export=DIRexport HTML to directory instead of running server