OLD | NEW |
1 # CMS # | 1 # CMS # |
2 | 2 |
3 We use this CMS for [adblockplus.org](https://github.com/adblockplus/web.adblock
plus.org/) | 3 We use this CMS for [adblockplus.org](https://github.com/adblockplus/web.adblock
plus.org/) |
4 and related websites. It converts a directory with content data into static | 4 and related websites. It converts a directory with content data into static |
5 files. You are free to use it for other projects but please keep in mind that we | 5 files. You are free to use it for other projects but please keep in mind that we |
6 make no stability guarantees whatsoever and might change functionality any time. | 6 make no stability guarantees whatsoever and might change functionality any time. |
7 | 7 |
8 ## How to use ## | 8 ## How to use ## |
9 | 9 |
10 ### Running the test server ### | 10 ### Running the test server ### |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 * `locale`: Locale code of the page language | 262 * `locale`: Locale code of the page language |
263 * `available_locales`: Locale codes of all languages available for this page | 263 * `available_locales`: Locale codes of all languages available for this page |
264 | 264 |
265 Following custom filters can be used: | 265 Following custom filters can be used: |
266 | 266 |
267 * `translate(default, name, comment=None)`: translates the given default string | 267 * `translate(default, name, comment=None)`: translates the given default string |
268 and string name for the current page and locale. The string name should be | 268 and string name for the current page and locale. The string name should be |
269 unique for the page but otherwise is only seen by the translators. Optionally | 269 unique for the page but otherwise is only seen by the translators. Optionally |
270 a comment (description) can be specified to help provide the translators with | 270 a comment (description) can be specified to help provide the translators with |
271 additional context. | 271 additional context. |
272 * `linkify(url)`: generates an `<a href="...">` tag for the URL. If the URL is | 272 * `linkify(url, locale=None, **attrs)`: generates an `<a href="...">` tag for |
273 a page name it will be converted into a link to the most appropriate page | 273 the URL. If the URL is a page name it will be converted into a link to the |
274 language. | 274 most appropriate page language. The language used can also be specified |
| 275 manually with the locale parameter. Any further keyword arguments passed |
| 276 are turned into additional HTML attributes for the tag. |
275 * `toclist(html)`: extracts a list of headings from HTML code, this can be used | 277 * `toclist(html)`: extracts a list of headings from HTML code, this can be used |
276 to generate a table of contents. | 278 to generate a table of contents. |
277 | 279 |
278 The following global functions can be used: | 280 The following global functions can be used: |
279 | 281 |
280 * `get_string(name, page=None)`: retrieves a string from a locale file. | 282 * `get_string(name, page=None)`: retrieves a string from a locale file. |
281 Unless a page is specified the locale file matching the name of the current | 283 Unless a page is specified the locale file matching the name of the current |
282 page is used. | 284 page is used. |
283 * `get_page_content(page, locale=None)`: returns a dictionary of the content | 285 * `get_page_content(page, locale=None)`: returns a dictionary of the content |
284 and params for the given page and locale. Locale defaults to the current one | 286 and params for the given page and locale. Locale defaults to the current one |
(...skipping 29 matching lines...) Expand all Loading... |
314 filter is invoked. For more information on Jinja2 filters see | 316 filter is invoked. For more information on Jinja2 filters see |
315 [official documentation](http://jinja.pocoo.org/docs/dev/api/#writing-filters). | 317 [official documentation](http://jinja.pocoo.org/docs/dev/api/#writing-filters). |
316 | 318 |
317 ### Custom functions and variables ### | 319 ### Custom functions and variables ### |
318 | 320 |
319 The `globals` directory can define custom Jinja2 globals which will be available | 321 The `globals` directory can define custom Jinja2 globals which will be available |
320 in all Jinja2 templates. Typically, this is used for custom functions. The file | 322 in all Jinja2 templates. Typically, this is used for custom functions. The file |
321 name should match the name of the function or variable to be defined, and export | 323 name should match the name of the function or variable to be defined, and export |
322 a variable with that name. E.g. `globals/myfunction.py` can define a function | 324 a variable with that name. E.g. `globals/myfunction.py` can define a function |
323 called `myfunction` that will become available to all Jinja2 templates. | 325 called `myfunction` that will become available to all Jinja2 templates. |
OLD | NEW |