-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdjango2ptml.awk
More file actions
executable file
·51 lines (45 loc) · 978 Bytes
/
django2ptml.awk
File metadata and controls
executable file
·51 lines (45 loc) · 978 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/awk -f
# this file processes django template files to turn them into ptml files
BEGIN {
in_content = 0
error = 0
INDENT1 = " "
INDENT2 = INDENT1 INDENT1
INDENT3 = INDENT2 INDENT1
}
/{% block content %}/ {
in_content = 1
print "<!DOCTYPE html>"
print "<html>"
print INDENT1 "<head>"
print "<!--include head.txt -->"
print INDENT2 "<title>"
print INDENT3 title
print INDENT2 "</title>"
print INDENT1 "</head>"
print ""
print INDENT1 "<body>"
print INDENT2 "<div class=\"wrapper\">"
print "<!--include navbar.txt -->"
print INDENT3 "<div id=\"content\">"
print INDENT3 "<h1>"
print INDENT3 title
print INDENT3 "</h1>"
next
}
/{% endblock content %}/ {
next
}
{
if(in_content) {
print INDENT3 $0
}
}
END {
if(!error) {
print INDENT3 "</div>"
print INDENT2 "</div>"
print INDENT1 "</body>"
print "</html>"
}
}