Show More
@@ -7,7 +7,7 b' import IPython.ipapi' | |||||
7 | ip = IPython.ipapi.get() |
|
7 | ip = IPython.ipapi.get() | |
8 |
|
8 | |||
9 | from string import Template |
|
9 | from string import Template | |
10 | import sys |
|
10 | import sys,os | |
11 |
|
11 | |||
12 | from IPython.Itpl import itplns |
|
12 | from IPython.Itpl import itplns | |
13 |
|
13 | |||
@@ -21,7 +21,7 b' def toclip_w32(s):' | |||||
21 | import win32con |
|
21 | import win32con | |
22 | cl.OpenClipboard() |
|
22 | cl.OpenClipboard() | |
23 | cl.EmptyClipboard() |
|
23 | cl.EmptyClipboard() | |
24 | cl.SetClipboardText( s ) |
|
24 | cl.SetClipboardText( s.replace('\n','\r\n' )) | |
25 | cl.CloseClipboard() |
|
25 | cl.CloseClipboard() | |
26 |
|
26 | |||
27 | try: |
|
27 | try: | |
@@ -43,6 +43,9 b' def render(tmpl):' | |||||
43 |
|
43 | |||
44 | => returns "Submission report, author: Bob" and copies to clipboard on win32 |
|
44 | => returns "Submission report, author: Bob" and copies to clipboard on win32 | |
45 |
|
45 | |||
|
46 | # if template exist as a file, read it. Note: ;f hei vaan => f("hei vaan") | |||
|
47 | $ ;render c:/templates/greeting.txt | |||
|
48 | ||||
46 | Template examples (Ka-Ping Yee's Itpl library): |
|
49 | Template examples (Ka-Ping Yee's Itpl library): | |
47 |
|
50 | |||
48 | Here is a $string. |
|
51 | Here is a $string. | |
@@ -54,6 +57,9 b' def render(tmpl):' | |||||
54 | Here is a $dictionary['member']. |
|
57 | Here is a $dictionary['member']. | |
55 | """ |
|
58 | """ | |
56 |
|
59 | |||
|
60 | if os.path.isfile(tmpl): | |||
|
61 | tmpl = open(tmpl).read() | |||
|
62 | ||||
57 | res = itplns(tmpl, ip.user_ns) |
|
63 | res = itplns(tmpl, ip.user_ns) | |
58 | toclip(res) |
|
64 | toclip(res) | |
59 | return res |
|
65 | return res |
General Comments 0
You need to be logged in to leave comments.
Login now