Plim Documentation

https://pypip.in/v/Plim/badge.png https://pypip.in/d/Plim/badge.png https://api.travis-ci.org/avanov/Plim.png https://coveralls.io/repos/avanov/Plim/badge.png?branch=develop

Plim is a Python port of Ruby’s Slim template language built on top of Mako Templates. It uses Mako’s preprocessor feature to translate its syntax into a valid HTML/Mako markup.

Installation

pip install Plim

Tests

Plim provides an extensive test suite based on nosetests. You can run the tests with the following command

python setup.py nosetests

Coverage statistics are available online.

Detailed example

/ base.html
--------------------------
doctype html
html = next.body()
/ helpers.html
--------------------------
-def other_headers()
    meta charset="utf-8"
    link rel="stylesheet" href="/static/css/main.css"
/ layout.html
--------------------------
-inherit base.html
-namespace name="helper" helpers.html

head
  title Plim Example
  meta name="keywords" content="template language"
  = helper.other_headers()

  script
    /* "script" and "style" blocks do not require explicit literal indicator "|"  */
    $(content).do_something();

  style
    body {
      background:#FFF;
      }

  -scss
    /* SCSS/SASS extension */
    @option compress: no;
    .selector {
      a {
        display: block;
      }
      strong {
        color: blue;
      }
    }

  -coffee
    # CoffeeScript extension
    square = (x) -> x * x

body
  h1 Markup examples
  #content.example1
    p Nest by indentation
    <div>
      p Mix raw HTML and Plim markup
    </div>

    -md
      Use Markdown
      ============

      See the syntax on [this page][1].

      [1]: http://daringfireball.net/projects/markdown/basics

    -rest
      or Use reStructuredText
      =======================

      See the syntax on `this page`_.

      .. _this page: http://docutils.sourceforge.net/docs/user/rst/quickref.html


  -if items
    table: -for item in items: tr
      td = item.name
      td = item.price
  -elif show_empty
    p No items found
  -else
    a href=request.route_url('items.add') =, _('Add items')

  -unless user.authenticated
    p Please, sign in.
  -else
    p Welcome, ${user.name}!
    ul
      --- i = 0
          limit = 5

      -while i < limit
        li#idx-${i}.up: a href='#' title="Title" == i
        --- i += 1

      -until i < 0
        li#idx-${i}.down-${i}: a href='''#''' title="""Title""" ==, i
        --- i -= 1

  #footer
    Copyright &copy; 2014.
    -include footer_links.html

= render('tracking_code')

Indices and tables