|
| 1 | +/** |
| 2 | + * Lists all builtin filters and their arguments. |
| 3 | + */ |
| 4 | +interface Functions { |
| 5 | + |
| 6 | + /** |
| 7 | + * <p>The block function is used to render the contents of a block more than once. |
| 8 | + * It is not to be confused with the block tag which is used to declare blocks.</p> |
| 9 | + * |
| 10 | + * <p>The following example will render the contents of the "post" block twice; once where it |
| 11 | + * was declared and again using the block function:</p> |
| 12 | + * |
| 13 | + * <code><pre> |
| 14 | + * {% block "post" %} content {% endblock %} |
| 15 | + * |
| 16 | + * {{ block("post") }} |
| 17 | + * </pre></code> |
| 18 | + * |
| 19 | + * The above example will output the following: |
| 20 | + * |
| 21 | + * <code><pre> |
| 22 | + * content |
| 23 | + * |
| 24 | + * content |
| 25 | + * </pre></code> |
| 26 | + * @param blockName |
| 27 | + */ |
| 28 | + block(String blockName); |
| 29 | + |
| 30 | + /** |
| 31 | + * <p>The i18n function is used to retrieve messages from a locale-specific ResourceBundle. |
| 32 | + * Every PebbleTemplate is assigned a default locale from the PebbleEngine. At the point of evaluation, |
| 33 | + * this locale can be changed with an argument to the evaluate(...) method of the individual template.</p> |
| 34 | + * |
| 35 | + * <p>The i18n function wraps around ResourceBundle.getBundle(name, locale).getObject(key). |
| 36 | + * The first argument to the i18n function is the name of the bundle and the second argument is the key |
| 37 | + * within the bundle.</p> |
| 38 | + * |
| 39 | + * <code><pre> |
| 40 | + * {{ i18n("messages","greeting") }} |
| 41 | + * </pre></code> |
| 42 | + * |
| 43 | + * <p>The above example assumes you have messages.properties on your classpath and that that file contains |
| 44 | + * a key by the name of greeting. If the locale of that template was es_US for example, it would look |
| 45 | + * for a message_es_US.properties file instead.</p> |
| 46 | + * |
| 47 | + * <p>Going a little further, you can use variables within your message and pass a list of params |
| 48 | + * to this function which will replace your variables using MessageFormat:</p> |
| 49 | + * |
| 50 | + * <code><pre> |
| 51 | + * {# greeting.someone=Hello, {0} #} |
| 52 | + * {{ i18n("messages","greeting", "Jacob") }} |
| 53 | + * |
| 54 | + * {# output: Hello, Jacob #} |
| 55 | + * </pre></code> |
| 56 | + * |
| 57 | + * @param bundle |
| 58 | + * @param key |
| 59 | + * @param params |
| 60 | + */ |
| 61 | + i18n(String bundle, String key, Object... params); |
| 62 | + |
| 63 | + /** |
| 64 | + * The max function will return the largest of it's numerical arguments. |
| 65 | + * |
| 66 | + * <code><pre> |
| 67 | + * {{ max(user.age, 80) }} |
| 68 | + * </pre></code> |
| 69 | + * |
| 70 | + * @param left |
| 71 | + * @param right |
| 72 | + */ |
| 73 | + max(Object left, Object right); |
| 74 | + |
| 75 | + /** |
| 76 | + * The min function will return the smallest of it's numerical arguments. |
| 77 | + * |
| 78 | + * <code><pre> |
| 79 | + * {{ min(user.age, 80) }} |
| 80 | + * </pre></code> |
| 81 | + * |
| 82 | + * @param left |
| 83 | + * @param right |
| 84 | + */ |
| 85 | + min(Object left, Object right); |
| 86 | + |
| 87 | + /** |
| 88 | + * <p>The parent function is used inside of a block to render the content that the parent template |
| 89 | + * would have rendered inside of the block had the current template not overriden it. It is similar |
| 90 | + * to Java's super keyword.</p> |
| 91 | + * |
| 92 | + * <p>Let's assume you have a template, "parent.peb" that looks something like this:</p> |
| 93 | + * |
| 94 | + * <code><pre> |
| 95 | + * {% block "content" %} |
| 96 | + * parent contents |
| 97 | + * {% endblock %} |
| 98 | + * </pre></code> |
| 99 | + * |
| 100 | + * <p>And then you have another template, "child.peb" that extends "parent.peb":</p> |
| 101 | + * |
| 102 | + * <code><pre> |
| 103 | + * {% extends "parent.peb" %} |
| 104 | + * |
| 105 | + * {% block "content" %} |
| 106 | + * child contents |
| 107 | + * {{ parent() }} |
| 108 | + * {% endblock %} |
| 109 | + * </pre></code> |
| 110 | + * |
| 111 | + * <p>The output will look something like the following:</p> |
| 112 | + * |
| 113 | + * <code><pre> |
| 114 | + * parent contents |
| 115 | + * child contents |
| 116 | + * </pre></code> |
| 117 | + */ |
| 118 | + parent(); |
| 119 | + |
| 120 | + /** |
| 121 | + * The range function will return a list containing an arithmetic progression of numbers: |
| 122 | + * |
| 123 | + * <code><pre> |
| 124 | + * {% for i in range(0, 3) %} |
| 125 | + * {{ i }}, |
| 126 | + * {% endfor %} |
| 127 | + * |
| 128 | + * {# outputs 0, 1, 2, 3, #} |
| 129 | + * </pre></code> |
| 130 | + * |
| 131 | + * When step is given (as the third parameter), it specifies the increment (or decrement): |
| 132 | + * |
| 133 | + * <code><pre> |
| 134 | + * {% for i in range(0, 6, 2) %} |
| 135 | + * {{ i }}, |
| 136 | + * {% endfor %} |
| 137 | + * |
| 138 | + * {# outputs 0, 2, 4, 6, #} |
| 139 | + * </pre></code> |
| 140 | + * |
| 141 | + * Pebble built-in .. operator is just a shortcut for the range function with a step of 1+ |
| 142 | + * |
| 143 | + * <code><pre> |
| 144 | + * {% for i in 0..3 %} |
| 145 | + * {{ i }}, |
| 146 | + * {% endfor %} |
| 147 | + * |
| 148 | + * {# outputs 0, 1, 2, 3, #} |
| 149 | + * </pre></code> |
| 150 | + */ |
| 151 | + range(int start, int end, int step); |
| 152 | +} |
0 commit comments