forked from ponyorm/pony
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes in template syntax: & -> $, etc.
git-svn-id: http://pony.tigris.org/svn/pony/trunk@77 698dff77-f410-0410-8918-cf622e150f36
- Loading branch information
Showing
8 changed files
with
150 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
root { | ||
<html> | ||
<head> | ||
<title>University &text{university/@name}</title> | ||
<title>University $text{university/@name}</title> | ||
<link rel="stylesheet" type="text/css" href="university.css" /> | ||
</head> | ||
<body> | ||
<h1>List of students:</h1> | ||
&transform{university/groups/group} | ||
$transform{university/groups/group} | ||
</body> | ||
</html> | ||
} | ||
|
||
group { | ||
<div> | ||
<h2>Group &text{@number}</h2> | ||
<h2>Group $text{@number}</h2> | ||
<p> | ||
Count of students: &text{count(students)},<br> | ||
among them &text{count(student[@type="contract"])} of contract /> | ||
Count of students: $text{count(students)},<br> | ||
among them $text{count(student[@type="contract"])} of contract /> | ||
</p> | ||
<ol>&transform{student}</ol> | ||
<ol>$transform{student}</ol> | ||
</div> | ||
} | ||
|
||
student { <li class="@type">&text{.}</li> } | ||
student { <li class="@type">$text{.}</li> } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,52 @@ | ||
|
||
&& | ||
&// comment | ||
&/* comment */ | ||
$$ | ||
$// comment | ||
$/* comment */ | ||
|
||
&if(expr) { text } | ||
&elif(expr) { text } | ||
&else { text } | ||
$if(expr) { text } | ||
$elif(expr) { text } | ||
$else { text } | ||
|
||
&for(var in expr) { | ||
$for(var in expr) { | ||
text | ||
&row{text1}{text2}{text3} | ||
&row(i,j){text} | ||
&row("odd"){text} &// &row(1,2){text} | ||
&row("even"){text} &// &row(2,2){text} | ||
&row("first"){text} | ||
&row("not first"){text} | ||
&row("last"){text} | ||
&row("not last"){text} | ||
} &separator { | ||
$row{text1}{text2}{text3} | ||
$row(i,j){text} | ||
$row("odd"){text} $// $row(1,2){text} | ||
$row("even"){text} $// $row(2,2){text} | ||
$row("first"){text} | ||
$row("not first"){text} | ||
$row("last"){text} | ||
$row("not last"){text} | ||
} $separator { | ||
text | ||
} &else { | ||
} $else { | ||
text | ||
} | ||
|
||
&{text} &// localization | ||
${text} $// localization | ||
|
||
&list(expr){text} | ||
$list(expr){text} | ||
|
||
&link(expr, attr=value, ...){text} | ||
$link(expr, attr=value, ...){text} | ||
|
||
------------------------------------------------ | ||
|
||
&myfunc(1, 2, a=3, b=4){ text1 }{ text2 }&c={ text3 }&d={ text4 } | ||
$myfunc(1, 2, a=3, b=4){ text1 }{ text2 }$c={ text3 }$d={ text4 } | ||
|
||
|
||
&layout(title="hello, world!", navsize=160, navleft=True) | ||
&header={ | ||
$layout(title="hello, world!", navsize=160, navleft=True) | ||
$header={ | ||
<h1>This is page header!</h1> | ||
}&footer={ | ||
}$footer={ | ||
<small>All right reserved</small> | ||
}&navbar={ | ||
}$navbar={ | ||
<ul> | ||
<li>item1 | ||
<li>item2 | ||
</ul> | ||
}&content={ | ||
}$content={ | ||
|
||
&unit{ text } | ||
&columns("1/4", "1/4", "1/2") { text }{ text }{ text } | ||
$unit{ text } | ||
$columns("1/4", "1/4", "1/2") { text }{ text }{ text } | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
$layout("Greeting to " + self.name) | ||
{ | ||
<h1>Hello, $self.name!</h1> | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,28 @@ | ||
<html> | ||
<head><title>&(self.title)</title></head> | ||
<head><title>$self.title</title></head> | ||
<body> | ||
<h1>&(self.title)</h1> | ||
<p>&(self.text) | ||
&for(record in self.records) { | ||
<h2>&(record.title)</h2> | ||
&for(paragraph in record.paragraphs) { | ||
<p>&(convert2html(paragraph)) | ||
<h1>$self.title</h1> | ||
<p>$self.text | ||
$for(record in self.records) { | ||
<h2>$record.title</h2> | ||
$for(paragraph in record.paragraphs) { | ||
<p>$convert2html(paragraph) | ||
} | ||
&if(record.comments) { | ||
$if(record.comments) { | ||
<h3>comments:</h3> | ||
<table> | ||
&for(comment in record.comments) { | ||
$for(comment in record.comments) { | ||
<tr><td width="10%"> | ||
&(comment.date)<br> | ||
&(comment.author) | ||
$comment.date<br> | ||
$comment.author | ||
</td><td> | ||
&(convert2html(comment.text)) | ||
$convert2html(comment.text) | ||
</td></tr> | ||
} &separator { | ||
} $separator { | ||
<tr><td colspan=2></td></tr> | ||
} | ||
</table> | ||
} &// if | ||
} &// for | ||
} $// if | ||
} $// for | ||
<body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from pony.templating import html | ||
|
||
def layout(title, content): | ||
return html(""" | ||
<html> | ||
<head><title>$title</title></head> | ||
<body> | ||
$content | ||
</body></html> | ||
""") | ||
|
||
class A(object): | ||
def __init__(self, name): | ||
self.name = name | ||
def hello(self): | ||
return html() | ||
|
||
a = A('John') | ||
print a.hello() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from pony.main import * | ||
|
||
@http | ||
@html | ||
def index1(self): | ||
print '<html><head>' | ||
print '<title>%s</title>' % self.title | ||
print '<link rel="stylesheet" type="text/css" href="%s">' % self.css | ||
print '</head><body>' | ||
print '<h1>%s</h1>' % self.greeting.upper() | ||
print '<div id="main">' | ||
print '<ul class="main-list">' | ||
for text in self.list_content: | ||
print '<li>%s</li>' % text | ||
print '</ul></div>' | ||
print '</body></html>' | ||
|
||
@http | ||
@html | ||
def index2(self): | ||
with tag.html: | ||
with tag.head: | ||
print tag.title(self.title) | ||
print tag.link(rel="stylesheet", type="text/css", href=self.css) | ||
with tag.body: | ||
print tag.h1(self.greeting.upper()) | ||
with tag.div(id="main"): | ||
with tag.ul(class_="main-list"): | ||
for text in self.list_content: print tag.li(text) | ||
|
||
@http | ||
def index3(self): | ||
return html(""" | ||
<html><head> | ||
<title>$self.title</title> | ||
<link rel="stylesheet" type="text/css" href="$self.css"> | ||
</head><body> | ||
<h1>$self.greeting.upper()</h1> | ||
<div id="main"> | ||
<ul class="main-list"> | ||
$(for text in self.list_content){<li>$text</li>} | ||
</ul> | ||
</div> | ||
</body></html> | ||
""") | ||
|
||
start_http_server('localhost:8080') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters