Skip to content

Commit 1fc7d15

Browse files
author
Max Avanov
committed
Change the behaviour of ",", "=," and "==," operators.
1 parent 980f7d2 commit 1fc7d15

15 files changed

+331
-205
lines changed

CHANGES

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Changelog
22
================
33

44

5-
0.6
5+
0.7
66
------------
77

88
Initial public release.

LICENSE

+15-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1-
The MIT License (MIT)
1+
This is the MIT license: http://www.opensource.org/licenses/mit-license.php
22

3-
Copyright (c) 2012 Maxim Avanov
3+
Copyright (C) 2012 Maxim Avanov, see AUTHORS for more details.
44

5-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this
6+
software and associated documentation files (the "Software"), to deal in the Software
7+
without restriction, including without limitation the rights to use, copy, modify, merge,
8+
publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
9+
to whom the Software is furnished to do so, subject to the following conditions:
610

7-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11+
The above copyright notice and this permission notice shall be included in all copies or
12+
substantial portions of the Software.
813

9-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
16+
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
17+
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
18+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19+
DEALINGS IN THE SOFTWARE.

docs/conf.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@
4848
# built documents.
4949
#
5050
# The short X.Y version.
51-
version = '0.5'
51+
version = '0.7'
5252
# The full version, including alpha/beta/rc tags.
53-
release = '0.5.3'
53+
release = '0.7.0'
5454

5555
# The language for content autogenerated by Sphinx. Refer to documentation
5656
# for a list of supported languages.

docs/en/frameworks.txt

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
=======================
2+
Framework Integration
3+
=======================
4+
5+
6+
Pyramid
7+
=========
8+

docs/en/nutshell.txt

+241
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,241 @@
1+
============================
2+
In a Nutshell
3+
============================
4+
5+
Plim is a Python port of `Ruby's Slim template language <http://slim-lang.com/>`_
6+
built on top of the `Mako Templates <http://www.makotemplates.org/>`_.
7+
It exploits `Mako's preprocessor feature <http://docs.makotemplates.org/en/latest/usage.html?highlight=preprocessor#api-reference>`_
8+
to translate its syntax to a valid HTML/Mako markup.
9+
10+
11+
Installation
12+
=============
13+
14+
.. code-block:: bash
15+
16+
pip install Plim
17+
18+
19+
Tests
20+
=======
21+
22+
Plim provides an extensive test suite based on `nosetests <http://nose.readthedocs.org/en/latest/>`_.
23+
You can run the tests with the following command
24+
25+
.. code-block:: bash
26+
27+
python setup.py nosetests
28+
29+
30+
31+
Syntax Highlighters
32+
======================
33+
34+
At this moment, Plim doesn't have syntax highlighters.
35+
36+
But, at a starting point you can use
37+
`Slim syntax highlighters <https://github.com/stonean/slim#syntax-highlighters>`_,
38+
since Most of the Plim syntax is the same as of Slim.
39+
40+
41+
Syntactic Differences
42+
=====================
43+
44+
Plim is *not the exact* port of Slim. Here is the full list of differences.
45+
46+
47+
#. Slim has the ( ``'`` ), ( ``='`` ), and ( ``=='`` ) `line indicators <https://github.com/stonean/slim#line-indicators>`_.
48+
In Plim, single quote has been replaced by the comma char ( ``,`` ):
49+
50+
.. code-block:: slim
51+
52+
, value
53+
=, value
54+
==, value
55+
56+
57+
The change was made in order to get rid of the syntactic ambiguities like these:
58+
59+
.. code-block:: plim
60+
61+
/ Is this an empty python string or a syntax error caused by the unclosed single quote?
62+
=''
63+
64+
/ Is this a python string 'u' ('u''' is the correct python syntax) or
65+
a syntax error caused by the unclosed unicode docstring?
66+
='u'''
67+
68+
Meanwhile, the comma char is not allowed at the beginning of python expression,
69+
therefore the following code samples are consistent:
70+
71+
.. code-block:: plim
72+
73+
/ Syntax error at mako runtime caused by the unclosed single quote
74+
=,'
75+
76+
/ Correct and consistent. Produces an explicit whitespace
77+
followed by empty unicode string
78+
=,u''
79+
80+
81+
In addition, the comma-syntax seems more natural, since in formal writing we also add a whitespace
82+
between a comma and the following word (in contrast to apostrophes, which are usually
83+
written together with words).
84+
85+
86+
87+
#. Unlike Slim, Plim does not support square or curly braces for wrapping tag attributes.
88+
You can use only parentheses ``()``:
89+
90+
.. code-block:: slim
91+
92+
/ For attributes wrapping we can use only parentheses
93+
p(title="Link Title")
94+
h1 class=(item.id == 1 and 'one' or 'unknown') Title
95+
96+
/ Square and curly braces are allowed only in Python and Mako expressions
97+
a#idx-${item.id} href=item.get_link(
98+
**{'argument': 'value'}) = item.attrs['title']
99+
100+
101+
#. In Plim, all html tags **MUST** be written in lowercase.
102+
103+
This restriction was introduced to support Implicit Litaral Block feature.
104+
105+
.. code-block:: slim
106+
107+
doctype 5
108+
html
109+
head
110+
title Page Title
111+
body
112+
p
113+
| Hello, Explicit Literal Block!
114+
p
115+
Hello, Implicit Literal Block!
116+
117+
118+
#. Plim does not distinguish between control structures and embedded filters.
119+
120+
In Slim, you would write ``-if``, ``-for``, and ``coffee:`` (without preceding dash,
121+
but with the colon sign at the tail).
122+
But in Plim, you must write ``-if``, ``-for``, and ``-coffee``.
123+
124+
125+
126+
Full Example
127+
==============================
128+
129+
.. code-block:: plim
130+
131+
/ base.html
132+
-------------------------
133+
doctype html
134+
html = next.body()
135+
136+
137+
.. code-block:: plim
138+
139+
/ helpers.html
140+
-------------------------
141+
-def other_headers()
142+
meta charset="utf-8"
143+
link rel="stylesheet" href="/static/css/main.css"
144+
145+
146+
.. code-block:: plim
147+
148+
/ layout.html
149+
-------------------------
150+
-inherit base.html
151+
-namespace name="helper" helpers.html
152+
153+
head
154+
title Plim Example
155+
meta name="keywords" content="template language"
156+
= helper.other_headers()
157+
158+
script
159+
/* "script" and "style" blocks do not require explicit literal indicator "|" */
160+
$(content).do_something();
161+
162+
style
163+
body {
164+
background:#FFF;
165+
}
166+
167+
-scss
168+
/* SCSS/SASS extension */
169+
@option compress: no;
170+
.selector {
171+
a {
172+
display: block;
173+
}
174+
strong {
175+
color: blue;
176+
}
177+
}
178+
179+
-coffee
180+
# CoffeeScript extension
181+
square = (x) -> x * x
182+
183+
body
184+
h1 Markup examples
185+
#content.example1
186+
p Nest by indentation
187+
<div>
188+
p Mix raw HTML and Plim markup
189+
</div>
190+
191+
-md
192+
Use Markdown
193+
============
194+
195+
See the syntax on [this page][1].
196+
197+
[1]: http://daringfireball.net/projects/markdown/basics
198+
199+
-rest
200+
or Use reStructuredText
201+
=======================
202+
203+
See the syntax on `this page`_.
204+
205+
.. _this page: http://docutils.sourceforge.net/docs/user/rst/quickref.html
206+
207+
208+
-if items
209+
table
210+
-for item in items
211+
tr
212+
td = item.name
213+
td = item.price
214+
-elif show_empty
215+
p No items found
216+
-else
217+
a href=request.route_url('items.add') =, _('Add items')
218+
219+
-unless user.authenticated
220+
p Please, sign in.
221+
-else
222+
p Welcome, ${user.name}!
223+
ul
224+
-python
225+
i = 0
226+
limit = 5
227+
228+
-while i < limit
229+
li#idx-${i}.up: a href='#' title="Title" == i
230+
-py i += 1
231+
232+
-until i < 0
233+
li#idx-${i}.down-${i}: a href='''#''' title="""Title""" ==, i
234+
-python
235+
i -= 1
236+
237+
#footer
238+
Copyright &copy; 2010 Andrew Stone.
239+
-include footer_links.html
240+
241+
= render('tracking_code')

0 commit comments

Comments
 (0)