| 1 |
Instructions to the Parser/Compiler |
| 2 |
=================================== |
| 3 |
|
| 4 |
|
| 5 |
#breakpoint |
| 6 |
----------- |
| 7 |
|
| 8 |
|
| 9 |
Syntax: |
| 10 |
|
| 11 |
:: |
| 12 |
|
| 13 |
#breakpoint |
| 14 |
|
| 15 |
{#breakpoint} is a debugging tool that tells the parser to stop |
| 16 |
parsing at a specific point. All source code from that point on |
| 17 |
will be ignored. |
| 18 |
|
| 19 |
The difference between {#breakpoint} and {#stop} is that {#stop} |
| 20 |
occurs in normal templates (e.g., inside an {#if}) but |
| 21 |
{#breakpoint} is used only when debugging Cheetah. Another |
| 22 |
difference is that {#breakpoint} operates at compile time, while |
| 23 |
{#stop} is executed at run time while filling the template. |
| 24 |
|
| 25 |
#compiler-settings |
| 26 |
------------------ |
| 27 |
|
| 28 |
|
| 29 |
Syntax: |
| 30 |
|
| 31 |
:: |
| 32 |
|
| 33 |
#compiler-settings |
| 34 |
key = value (no quotes) |
| 35 |
#end compiler-settings |
| 36 |
|
| 37 |
#compiler-settings reset |
| 38 |
|
| 39 |
The {#compiler-settings} directive overrides Cheetah's standard |
| 40 |
settings, changing how it parses source code and generates Python |
| 41 |
code. This makes it possible to change the behaviour of Cheetah's |
| 42 |
parser/compiler for a certain template, or within a portion of the |
| 43 |
template. |
| 44 |
|
| 45 |
The {reset} argument reverts to the default settings. With {reset}, |
| 46 |
there's no end tag. |
| 47 |
|
| 48 |
Here are some examples of what you can do: |
| 49 |
|
| 50 |
:: |
| 51 |
|
| 52 |
$myVar |
| 53 |
#compiler-settings |
| 54 |
cheetahVarStartToken = @ |
| 55 |
#end compiler-settings |
| 56 |
@myVar |
| 57 |
#compiler-settings reset |
| 58 |
$myVar |
| 59 |
|
| 60 |
:: |
| 61 |
|
| 62 |
## normal comment |
| 63 |
#compiler-settings |
| 64 |
commentStartToken = // |
| 65 |
#end compiler-settings |
| 66 |
|
| 67 |
// new style of comment |
| 68 |
|
| 69 |
#compiler-settings reset |
| 70 |
|
| 71 |
## back to normal comments |
| 72 |
|
| 73 |
:: |
| 74 |
|
| 75 |
#slurp |
| 76 |
#compiler-settings |
| 77 |
directiveStartToken = % |
| 78 |
#end compiler-settings |
| 79 |
|
| 80 |
%slurp |
| 81 |
%compiler-settings reset |
| 82 |
|
| 83 |
#slurp |
| 84 |
|
| 85 |
Here's a partial list of the settings you can change: |
| 86 |
|
| 87 |
|
| 88 |
#. syntax settings |
| 89 |
|
| 90 |
|
| 91 |
#. cheetahVarStartToken |
| 92 |
|
| 93 |
#. commentStartToken |
| 94 |
|
| 95 |
#. multilineCommentStartToken |
| 96 |
|
| 97 |
#. multilineCommentEndToken |
| 98 |
|
| 99 |
#. directiveStartToken |
| 100 |
|
| 101 |
#. directiveEndToken |
| 102 |
|
| 103 |
|
| 104 |
#. code generation settings |
| 105 |
|
| 106 |
|
| 107 |
#. commentOffset |
| 108 |
|
| 109 |
#. outputRowColComments |
| 110 |
|
| 111 |
#. defDocStrMsg |
| 112 |
|
| 113 |
#. useNameMapper |
| 114 |
|
| 115 |
#. useAutocalling |
| 116 |
|
| 117 |
#. reprShortStrConstants |
| 118 |
|
| 119 |
#. reprNewlineThreshold |
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
The meaning of these settings and their default values will be |
| 124 |
documented in the future. |
| 125 |
|
| 126 |
|