| 1 | #!/usr/bin/perl | ||
| 2 | |||
| 3 | #BOOTSTRAP-BEGIN | ||
| 4 | # This section of code will be replaced by lots of inline Perl modules | ||
| 5 | # to make the standalone jemplate script. | ||
| 6 | 29 | ▶ | use lib 'lib'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 29 | ▶ | use Jemplate 0.22; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | #BOOTSTRAP-END | ||
| 9 | |||
| 10 | 29 | Jemplate->main(@ARGV); | |
| 11 | |||
| 12 | =head1 Usage: | ||
| 13 | |||
| 14 | jemplate --runtime [runtime-opt] | ||
| 15 | |||
| 16 | jemplate --compile [compile-opt] template-list | ||
| 17 | |||
| 18 | jemplate --runtime [runtime-opt] --compile [compile-opt] template-list | ||
| 19 | |||
| 20 | jemplate --list template-list | ||
| 21 | |||
| 22 | Where C<--runtime> and C<runtime-opt> can include: | ||
| 23 | |||
| 24 | --runtime Equivalent to --ajax=ilinsky --json=json2 | ||
| 25 | --runtime=standard | ||
| 26 | |||
| 27 | --runtime=lite Same as --ajax=none --json=none | ||
| 28 | --runtime=jquery Same as --ajax=jquery --json=none | ||
| 29 | --runtime=yui Same as --ajax=yui --json=yui | ||
| 30 | --runtime=legacy Same as --ajax=gregory --json=json2 | ||
| 31 | |||
| 32 | --json By itself, equivalent to --json=json2 | ||
| 33 | --json=json2 Include http://www.json.org/json2.js for parsing/stringifying | ||
| 34 | --json=yui Use YUI: YAHOO.lang.JSON (requires external YUI) | ||
| 35 | --json=none Doesn't provide any JSON functionality except a warning | ||
| 36 | |||
| 37 | --ajax By itself, equivalent to --ajax=xhr | ||
| 38 | --ajax=jquery Use jQuery for Ajax get and post (requires external jQuery) | ||
| 39 | --ajax=yui Use YUI: yui/connection/connection.js (requires external YUI) | ||
| 40 | --ajax=xhr Use XMLHttpRequest (will automatically use --xhr=ilinsky if --xhr is not set) | ||
| 41 | --ajax=none Doesn't provide any Ajax functionality except a warning | ||
| 42 | |||
| 43 | --xhr By itself, equivalent to --xhr=ilinsky | ||
| 44 | --xhr=ilinsky Include http://code.google.com/p/xmlhttprequest/ | ||
| 45 | --xhr=gregory Include http://www.scss.com.au/family/andrew/webdesign/xmlhttprequest/ | ||
| 46 | |||
| 47 | --xxx Include XXX and JJJ helper functions | ||
| 48 | |||
| 49 | --compact Use the YUICompressor compacted version of the runtime | ||
| 50 | |||
| 51 | Where C<compile-opt> can include: | ||
| 52 | |||
| 53 | --start-tag | ||
| 54 | --end-tag | ||
| 55 | --pre-chomp | ||
| 56 | --post-chomp | ||
| 57 | --trim | ||
| 58 | --any-case | ||
| 59 | --eval | ||
| 60 | --noeval | ||
| 61 | -s, --source | ||
| 62 | |||
| 63 | See below for more information | ||
| 64 | |||
| 65 | =head2 Example: | ||
| 66 | |||
| 67 | Write the Jemplate runtime code into Jemplate.js, then | ||
| 68 | compile all the template files in the templates/ directory and put | ||
| 69 | the output in my-jemplate.js. | ||
| 70 | |||
| 71 | jemplate --runtime > Jemplate.js | ||
| 72 | jemplate --compile templates/* > my-jemplate.js | ||
| 73 | |||
| 74 | Do the same thing, but put the output into one file. | ||
| 75 | |||
| 76 | jemplate --runtime > my-jemplate.js | ||
| 77 | jemplate --compile templates/* >> my-jemplate.js | ||
| 78 | |||
| 79 | =head2 template-list: | ||
| 80 | |||
| 81 | The template-list is the list of template files that will be compiled. | ||
| 82 | If something in the list is a file, then the template name will be just | ||
| 83 | the file name. If it is a directory, then all the files under that | ||
| 84 | directory will be found, and the relative paths to those files will be | ||
| 85 | the template name. | ||
| 86 | |||
| 87 | So 'template/foo/bar.tt2' will be named 'bar.tt2', but 'template/' will | ||
| 88 | find a template named 'foo/bar.tt2'. | ||
| 89 | |||
| 90 | It is important to know what Jemplate thinks the template name will be | ||
| 91 | when you are writing templates or code that refers to other templates. | ||
| 92 | Use the --list option to check this. | ||
| 93 | |||
| 94 | =head1 Commands: | ||
| 95 | |||
| 96 | -r, --runtime | ||
| 97 | This flag tells Jemplate to print the Jemplate JavaScript | ||
| 98 | runtime code to STDOUT. You should redirect this output into | ||
| 99 | a .js file. | ||
| 100 | |||
| 101 | -c, --compile | ||
| 102 | The --compile flag tells Jemplate to actually compile templates. | ||
| 103 | The output is written to STDOUT. | ||
| 104 | |||
| 105 | -l, --list | ||
| 106 | Just print (STDOUT) the template names that Jemplate would use | ||
| 107 | from the template-list. | ||
| 108 | |||
| 109 | =head1 Template Toolkit Compile Options: | ||
| 110 | |||
| 111 | Jemplate allows you to specify the following Template Toolkit compile | ||
| 112 | time options. Full descriptions of these options are available at | ||
| 113 | L<http://www.template-toolkit.org/docs/plain/Manual/Config.html>. | ||
| 114 | |||
| 115 | These options may either be set as JEMPLATE_* environment variables or as | ||
| 116 | command line switches. | ||
| 117 | |||
| 118 | --start-tag (JEMPLATE_START_TAG) | ||
| 119 | Specify the starting template delimiter to use. Default is '[%'. | ||
| 120 | |||
| 121 | --end-tag (JEMPLATE_END_TAG) | ||
| 122 | Specify the ending template delimiter to use. Default is '%]'. | ||
| 123 | |||
| 124 | --pre-chomp (JEMPLATE_PRE_CHOMP) | ||
| 125 | Chomp leading whitespace automatically. Default is off. | ||
| 126 | |||
| 127 | --post-chomp (JEMPLATE_POST_CHOMP) | ||
| 128 | Chomp trailing whitespace automatically. Default is off. | ||
| 129 | |||
| 130 | --trim (JEMPLATE_TRIM) | ||
| 131 | Trim leading and trailing whitespace. Default is off. | ||
| 132 | |||
| 133 | --any-case (JEMPLATE_ANYCASE) | ||
| 134 | Allow lower or mixed case for template directives. Default is off. | ||
| 135 | |||
| 136 | --eval (--noeval) (JEMPLATE_EVAL_JAVASCRIPT) | ||
| 137 | Allow the execution of raw JavaScript. Default is on. | ||
| 138 | Use --noeval to disallow it. | ||
| 139 | |||
| 140 | =head1 Jemplate Options: | ||
| 141 | |||
| 142 | These compile time options are specific to Jemplate. | ||
| 143 | |||
| 144 | -s, --source | ||
| 145 | Include the original template source code as a JavaScript | ||
| 146 | comment next to each compiled template. | ||
| 147 | |||
| 148 | =cut | ||