diff options
Diffstat (limited to 'docs/template-variables.rst')
| -rw-r--r-- | docs/template-variables.rst | 116 |
1 files changed, 60 insertions, 56 deletions
diff --git a/docs/template-variables.rst b/docs/template-variables.rst index b9d3a9d..aeb254a 100644 --- a/docs/template-variables.rst +++ b/docs/template-variables.rst @@ -3,7 +3,7 @@ .. date: 2017-04-13 12:00:00 .. author: The Nikola Team -:Version: 8.1.3 +:Version: 8.2.0 :Author: Chris Warrick <chris@getnikola.com> Variables available in templates are listed below. @@ -41,45 +41,45 @@ Name Type Descript ================================== ================================== ================================================================================ ``_link`` function ``Nikola.link`` function ``abs_link`` function ``Nikola.abs_link`` function -``atom_path`` TranslatableSetting<str> ``ATOM_PATH`` setting +``atom_path`` TranslatableSetting[str] ``ATOM_PATH`` setting ``author_pages_generated`` bool False -``blog_author`` TranslatableSetting<str> ``BLOG_AUTHOR`` setting +``blog_author`` TranslatableSetting[str] ``BLOG_AUTHOR`` setting ``blog_email`` str ``BLOG_EMAIL`` setting -``blog_description`` TranslatableSetting<str> ``BLOG_DESCRIPTION`` setting -``blog_title`` TranslatableSetting<str> ``BLOG_TITLE`` setting +``blog_description`` TranslatableSetting[str] ``BLOG_DESCRIPTION`` setting +``blog_title`` TranslatableSetting[str] ``BLOG_TITLE`` setting ``blog_url`` str ``SITE_URL`` setting -``body_end`` TranslatableSetting<str> ``BODY_END`` setting +``body_end`` TranslatableSetting[str] ``BODY_END`` setting ``colorize_str_from_base_color`` function ``utils.colorize_str_from_base_color`` function ``color_hsl_adjust_hex`` function ``utils.color_hsl_adjust_hex`` function ``comment_system_id`` str ``COMMENT_SYSTEM_ID`` setting ``comment_system`` str ``COMMENT_SYSTEM`` setting -``content_footer`` TranslatableSetting<str> ``CONTENT_FOOTER`` setting +``content_footer`` TranslatableSetting[str] ``CONTENT_FOOTER`` setting ``data`` dict data files (from the ``data/`` directory) ``date_fanciness`` int ``DATE_FANCINESS`` setting -``date_format`` TranslatableSetting<str> ``DATE_FORMAT`` setting +``date_format`` TranslatableSetting[str] ``DATE_FORMAT`` setting ``exists`` function ``Nikola.file_exists`` function -``extra_head_data`` TranslatableSetting<str> ``EXTRA_HEAD_DATA`` setting +``extra_head_data`` TranslatableSetting[str] ``EXTRA_HEAD_DATA`` setting ``favicons`` tuple ``FAVICONS`` setting -``front_index_header`` TranslatableSetting<str> ``FRONT_INDEX_HEADER`` setting +``front_index_header`` TranslatableSetting[str] ``FRONT_INDEX_HEADER`` setting ``generate_atom`` bool ``GENERATE_ATOM`` setting ``generate_rss`` bool ``GENERATE_RSS`` setting ``global_data`` dict alias for ``data`` ``has_custom_css`` bool True if custom.css exists -``hidden_authors`` list<str> ``HIDDEN_AUTHORS`` setting -``hidden_categories`` list<str> ``HIDDEN_CATEGORIES`` setting -``hidden_tags`` list<str> ``HIDDEN_TAGS`` setting +``hidden_authors`` list[str] ``HIDDEN_AUTHORS`` setting +``hidden_categories`` list[str] ``HIDDEN_CATEGORIES`` setting +``hidden_tags`` list[str] ``HIDDEN_TAGS`` setting ``hide_sourcelink`` bool ``SHOW_SOURCELINK`` setting, negated ``index_display_post_count`` int ``INDEX_DISPLAY_POST_COUNT`` setting ``index_file`` str ``INDEX_FILE`` setting -``js_date_format`` TranslatableSetting<str> ``MOMENTJS_DATE_FORMAT`` setting, JSONified +``js_date_format`` TranslatableSetting[str] ``MOMENTJS_DATE_FORMAT`` setting, JSONified ``katex_auto_render`` str ``KATEX_AUTO_RENDER`` setting -``license`` TranslatableSetting<str> ``LICENSE`` setting +``license`` TranslatableSetting[str] ``LICENSE`` setting ``logo_url`` str ``LOGO_URL`` setting -``luxon_date_format`` TranslatableSetting<str> ``LUXON_DATE_FORMAT`` setting, JSONified +``luxon_date_format`` TranslatableSetting[str] ``LUXON_DATE_FORMAT`` setting, JSONified ``mathjax_config`` str ``MATHJAX_CONFIG`` setting -``messages`` dict<dict<str, str>> translated messages (``{language: {english: translated}}``) +``messages`` dict[dict[str, str]] translated messages (``{language: {english: translated}}``) ``meta_generator_tag`` bool ``META_GENERATOR_TAG`` setting -``momentjs_locales`` defaultdict<str, str> dictionary of available Moment.js locales +``momentjs_locales`` defaultdict[str, str] dictionary of available Moment.js locales ``multiple_authors_per_post`` bool ``MULTIPLE_AUTHORS_PER_POST`` setting ``navigation_links`` TranslatableSetting ``NAVIGATION_LINKS`` setting ``navigation_alt_links`` TranslatableSetting ``NAVIGATION_ALT_LINKS`` setting @@ -90,24 +90,24 @@ Name Type Descript ``posts_section_colors`` TranslatableSetting ``POSTS_SECTION_COLORS`` setting ``posts_section_descriptions`` Tss ``POSTS_SECTION_DESCRIPTIONS`` setting ``posts_section_from_meta`` bool ``POSTS_SECTION_FROM_META`` setting -``posts_section_name`` TranslatableSetting<str> ``POSTS_SECTION_NAME`` setting -``posts_section_title`` TranslatableSetting<str> ``POSTS_SECTION_TITLE`` setting +``posts_section_name`` TranslatableSetting[str] ``POSTS_SECTION_NAME`` setting +``posts_section_title`` TranslatableSetting[str] ``POSTS_SECTION_TITLE`` setting ``rel_link`` function ``Nikola.rel_link`` function ``rss_link`` str ``RSS_LINK`` setting -``search_form`` TranslatableSetting<str> ``SEARCH_FORM`` setting +``search_form`` TranslatableSetting[str] ``SEARCH_FORM`` setting ``set_locale`` function ``LocaleBorg.set_locale`` function (or None if not available) ``show_blog_title`` bool ``SHOW_BLOG_TITLE`` setting ``show_sourcelink`` bool ``SHOW_SOURCELINK`` setting ``site_has_comments`` bool whether or not a comment system is configured -``social_buttons_code`` TranslatableSetting<str> ``SOCIAL_BUTTONS_CODE`` setting +``social_buttons_code`` TranslatableSetting[str] ``SOCIAL_BUTTONS_CODE`` setting ``sort_posts`` function ``utils.sort_posts`` function ``smartjoin`` function ``utils.smartjoin`` function ``colorize_str`` function ``utils.colorize_str`` function -``template_hooks`` dict<str, TemplateHookRegistry> Template hooks registered by plugins +``template_hooks`` dict[str, TemplateHookRegistry] Template hooks registered by plugins ``theme_color`` str ``THEME_COLOR`` setting ``theme_config`` dict ``THEME_CONFIG`` setting ``timezone`` tzinfo Timezone object (represents the configured timezone) -``translations`` dict<str, str> ``TRANSLATIONS`` setting +``translations`` dict[str, str] ``TRANSLATIONS`` setting ``twitter_card`` dict ``TWITTER_CARD`` setting, defaults to an empty dictionary ``url_replacer`` function ``Nikola.url_replacer`` function ``url_type`` str ``URL_TYPE`` setting @@ -131,7 +131,7 @@ Name Type Description ``description`` str Description of the page ``is_rtl`` bool Whether or not the language is left-to-right ``lang`` str Current language -``pagekind`` list<str> List of strings that identify the type of this page `(docs)`__ +``pagekind`` list[str] List of strings that identify the type of this page `(docs)`__ ``title`` str Title of the page (taken from post, config, etc.) ``formatmsg`` function Wrapper over ``%`` string formatting ``striphtml`` function Strips HTML tags (Mako only) @@ -161,7 +161,7 @@ Variables available in post lists ============== ============= ============================================== Name Type Description ============== ============= ============================================== -``posts`` list<Post> List of post objects that appear in this list +``posts`` list[Post] List of post objects that appear in this list ``prevlink`` str Link to previous page ``nextlink`` str Link to next page ============== ============= ============================================== @@ -175,11 +175,11 @@ Variables available in indexes ============================== ============== =============================================================================== Name Type Description ============================== ============== =============================================================================== -``posts`` list<Post> List of post objects that appear in this list +``posts`` list[Post] List of post objects that appear in this list ``index_teasers`` bool ``INDEX_TEASERS`` setting ``show_index_page_navigation`` bool ``SHOW_INDEX_PAGE_NAVIGATION`` setting ``current_page`` int Number of current page -``page_links`` list<str> Links to different pages +``page_links`` list[str] Links to different pages ``prevlink`` str Link to previous page ``nextlink`` str Link to next page ``prevfeedlink`` str Link to previous page as an Atom feed @@ -191,7 +191,7 @@ Name Type Description Variables available in taxonomies --------------------------------- -Variable names enclosed in ``<>`` are dependent on the taxonomy. +Variable names enclosed in ``{}`` are dependent on the taxonomy. .. class:: table table-bordered table-striped @@ -238,11 +238,11 @@ Hierarchy-related variables are available if and only if ``has_hierarchy`` is Tr ================================================================== ====== ============================================================================================================================================================================== Name Type Description ================================================================== ====== ============================================================================================================================================================================== -``<overview_page_variable_name>`` str List of classifications -``<overview_page_items_variable_name>`` list List of items *(name, link)* -``<overview_page_items_variable_name + "_with_postcount">`` list List of items *(name, link, number of posts)* -``<overview_page_hierarchy_variable_name>`` list? List of hierarchies *(name, full name, path, link, indent levels, indent to change before, indent to change after)* -``<overview_page_hierarchy_variable_name + "_with_postcount">`` list? List of hierarchies, with added counts *(name, full name, path, link, indent levels, indent to change before, indent to change after, number of children, number of posts)* +``{overview_page_variable_name}`` str List of classifications +``{overview_page_items_variable_name}`` list List of items *(name, link)* +``{overview_page_items_variable_name + "_with_postcount"}`` list List of items *(name, link, number of posts)* +``{overview_page_hierarchy_variable_name}`` list? List of hierarchies *(name, full name, path, link, indent levels, indent to change before, indent to change after)* +``{overview_page_hierarchy_variable_name + "_with_postcount"}`` list? List of hierarchies, with added counts *(name, full name, path, link, indent levels, indent to change before, indent to change after, number of children, number of posts)* ``has_hierarchy`` bool Value of ``has_hierarchy`` for the taxonomy ``permalink`` str Permanent link to page ================================================================== ====== ============================================================================================================================================================================== @@ -257,9 +257,9 @@ Name Type Description =================== ============== ============================================================= ``kind`` str The classification name ``items`` list? List of items for ``list.tmpl`` *(title, permalink, None)* -``posts`` list<Post>? List of items for other templates +``posts`` list[Post]? List of items for other templates ``permalink`` str Permanent link to page -``other_languages`` list<tuple> List of triples ``(other_lang, other_classification, title)`` +``other_languages`` list[tuple] List of triples ``(other_lang, other_classification, title)`` =================== ============== ============================================================= Index-style classification pages have ``kind`` in addition to the usual index variables. @@ -274,7 +274,7 @@ Name Type Description =================== =========== ============================================================= ``items`` list? List of items ``permalink`` str Permanent link to page -``other_languages`` list<tuple> List of triples ``(other_lang, other_classification, title)`` +``other_languages`` list[tuple] List of triples ``(other_lang, other_classification, title)`` =================== =========== ============================================================= Hierarchical lists @@ -336,7 +336,7 @@ Name Type Description ``kind`` str Always ``"author"`` ``author`` str Author name ``rss_link`` str Link to RSS (HTML fragment) -``other_languages`` list<tuple> List of tuples ``(lang, author, name)`` of same author in other languages +``other_languages`` list[tuple] List of tuples ``(lang, author, name)`` of same author in other languages =================== =========== ========================================================================= @@ -350,11 +350,11 @@ Name Type Description =================== =========== ============================================================================= ``kind`` str Always ``"category"`` ``category`` str Category name -``category_path`` list<str> Category hierarchy +``category_path`` list[str] Category hierarchy ``rss_link`` str? Link to RSS (HTML fragment, only if using indexes) ``subcategories`` list List of subcategories (contains *name, link* tuples) ``tag`` str Friendly category name -``other_languages`` list<tuple> List of tuples ``(lang, category, name)`` of same category in other languages +``other_languages`` list[tuple] List of tuples ``(lang, category, name)`` of same category in other languages =================== =========== ============================================================================= Variables available in galleries @@ -386,8 +386,8 @@ Name Type Description ================== ========== ======================================== ``code`` str Highlighted source code (HTML fragment) ``crumbs`` list Breadcrumbs for this page -``folders`` list<str> List of subfolders -``files`` list<str> List of files in the folder +``folders`` list[str] List of subfolders +``files`` list[str] List of files in the folder ``source_link`` str Link to the source file ================== ========== ======================================== @@ -401,7 +401,7 @@ Name Type Description =================== =========== =========================================================================== ``section`` str Section name (internal) ``kind`` str Always ``"section"`` -``other_languages`` list<tuple> List of tuples ``(lang, section, name)`` of same section in other languages +``other_languages`` list[tuple] List of tuples ``(lang, section, name)`` of same section in other languages =================== =========== =========================================================================== Variables available in tag pages @@ -414,7 +414,7 @@ Name Type Description =================== =========== =================================================================== ``kind`` str Always ``"tag"`` ``tag`` str Tag name -``other_languages`` list<tuple> List of tuples ``(lang, tag, name)`` of same tag in other languages +``other_languages`` list[tuple] List of tuples ``(lang, tag, name)`` of same tag in other languages =================== =========== =================================================================== Variables available in the “Tags and categories” page (``tags.tmpl``) @@ -422,12 +422,16 @@ Variables available in the “Tags and categories” page (``tags.tmpl``) .. class:: table table-bordered table-striped -============== ====== =========================================================================================================== -Name Type Description -============== ====== =========================================================================================================== -``items`` list Tags *(name, link)* -``cat_items`` list Categories *(name, full name, path, link, indent levels, indent to change before, indent to change after)* -============== ====== =========================================================================================================== +========================= ====== =========================================================================================================== +Name Type Description +========================= ====== =========================================================================================================== +``items`` list Tags *(name, link)* +``cat_items`` list Categories *(name, full name, path, link, indent levels, indent to change before, indent to change after)* +``category_titles`` dict ``CATEGORY_TITLES`` setting (dict for the current language only) +``category_descriptions`` dict ``CATEGORY_DESCRIPTIONS`` setting (dict for the current language only) +``tag_titles`` dict ``TAG_TITLES`` setting (dict for the current language only) +``tag_descriptions`` dict ``TAG_DESCRIPTIONS`` setting (dict for the current language only) +========================= ====== =========================================================================================================== For more details about hierarchies, see `Hierarchical lists`_ @@ -442,7 +446,7 @@ Variables available in shortcodes Name Type Description ================== ========== =========================================================================== ``lang`` str Current language -``_args`` list<str> Arguments given to the shortcode +``_args`` list[str] Arguments given to the shortcode ``data`` str Shortcode contents ``post`` Post Post object (if available) ``filename`` str? file name, if ``shortcode_function.nikola_shortcode_pass_filename = True`` @@ -458,7 +462,7 @@ Variables available in post lists ================== ========== ===================================== Name Type Description ================== ========== ===================================== -``posts`` list<Post> Posts that are on the list +``posts`` list[Post] Posts that are on the list ``lang`` str Current language ``date_format`` str The date format for current language ``post_list_id`` str GUID of post list @@ -478,7 +482,7 @@ More docs: `nikola.post.Post on ReadTheDocs <https://nikola.readthedocs.io/en/la =================================================================== ========== ============================================================= Name Type Description =================================================================== ========== ============================================================= -``alltags`` list<str> All tags for the post +``alltags`` list[str] All tags for the post ``author(lang=None)`` str Localized author or ``BLOG_AUTHOR`` ``base_path`` str ``cache`` path with local ``os.sep`` ``category_from_destpath`` bool If category was set by ``CATEGORY_DESTPATH_AS_DEFAULT`` @@ -509,11 +513,11 @@ Name Type ``remaining_paragraph_count`` int Paragraph count after the teaser ``remaining_reading_time`` int Reading time after the teaser ``source_link`` str Absolute link to the post's source -``tags`` list<str> Tags for the current language -``tags_for_language(lang)`` list<str> Tags for a given language +``tags`` list[str] Tags for the current language +``tags_for_language(lang)`` list[str] Tags for a given language ``text(lang?, teaser_only?, strip_html?, show_read_more_link?, …)`` str The text of a post ``title(lang=None)`` str Localized title of post -``translated_to`` list<str> List of languages of post +``translated_to`` list[str] List of languages of post ``updated`` datetime Date of last update (from meta) ``use_in_feeds`` bool If this post should be displayed in feeds =================================================================== ========== ============================================================= |
