| 1 | [[PageOutline(2-5,Contents,pullout)]] |
| 2 | |
| 3 | = Genshi Macro = |
| 4 | |
| 5 | == Description == |
| 6 | |
| 7 | == Genshi processor for wiki pages == |
| 8 | |
| 9 | === Description === |
| 10 | |
| 11 | The GenshiMacro allows you to write and render Genshi templates directly |
| 12 | in wiki pages with a new ``Genshi`` processor. |
| 13 | |
| 14 | Your templates will have access to the request as ``req``, which can be |
| 15 | useful for tasks like URL generation, rendering form tokens for POST |
| 16 | requests, and checking for a logged-in user. |
| 17 | |
| 18 | '''Note: no security considerations whatsoever went into the making of |
| 19 | this plugin. It might be a terrible idea. If you happen to know that |
| 20 | it is, please let me know.''' |
| 21 | |
| 22 | === Configuration and Usage === |
| 23 | |
| 24 | To use the plugin, install it in your Trac environment and enable its |
| 25 | components in ``trac.ini``:: |
| 26 | |
| 27 | {{{ |
| 28 | [components] |
| 29 | genshimacro.* = enabled |
| 30 | }}} |
| 31 | |
| 32 | You can then write Genshi templates directly in wiki pages. |
| 33 | |
| 34 | |
| 35 | == Bugs/Feature Requests == |
| 36 | |
| 37 | Existing bugs and feature requests for GenshiMacro are |
| 38 | [report:9?COMPONENT=GenshiMacro here]. |
| 39 | |
| 40 | If you have any issues, create a |
| 41 | [http://trac-hacks.org/newticket?component=GenshiMacro&owner=ejucovy new ticket]. |
| 42 | |
| 43 | == Download == |
| 44 | |
| 45 | Download the zipped source from [download:genshimacro here]. |
| 46 | |
| 47 | == Source == |
| 48 | |
| 49 | You can check out GenshiMacro from [http://trac-hacks.org/svn/genshimacro here] using Subversion, or [source:genshimacro browse the source] with Trac. |
| 50 | |
| 51 | == Example == |
| 52 | |
| 53 | {{{ |
| 54 | #!html |
| 55 | |
| 56 | {{{ |
| 57 | #!Genshi |
| 58 | <div xmlns:py="http://genshi.edgewall.org/"> |
| 59 | <py:choose> |
| 60 | <py:when test="req.session.authenticated"> |
| 61 | <form method="POST" action="${req.href.newticket()}"> |
| 62 | <input type="text" name="field_summary" placeholder="My new ticket" |
| 63 | id="field-summary" /> |
| 64 | <input type="hidden" name="__FORM_TOKEN" value="${req.form_token}" /> |
| 65 | <input type="submit" /> |
| 66 | </form> |
| 67 | </py:when> |
| 68 | <py:otherwise> |
| 69 | <b>To file a new ticket, you'll need to |
| 70 | <a href="${req.href.login()}">log in</a> or |
| 71 | <a href="${req.href.register()}">create an account</a> |
| 72 | first.</b> |
| 73 | </py:otherwise> |
| 74 | </py:choose> |
| 75 | </div> |
| 76 | }}} |
| 77 | |
| 78 | }}} |
| 79 | |
| 80 | == Recent Changes == |
| 81 | |
| 82 | [[ChangeLog(genshimacro, 3)]] |
| 83 | |
| 84 | == Author/Contributors == |
| 85 | |
| 86 | '''Author:''' [wiki:ejucovy] [[BR]] |
| 87 | '''Maintainer:''' [wiki:ejucovy] [[BR]] |
| 88 | '''Contributors:''' |