标签:url ensure 程序 themes title exec handle rac ati
Each page in a Ghost theme belongs to a context, which determines which template is used, what data will be available and what content is output by the {{body_class}}
helper.
Ghost主题中的每个页面都属于一个上下文,它决定使用哪个模板、哪些数据可用以及{{body_class}}助手输出什么内容。
A Ghost publication follows a structure that allows URLs or routes to be mapped to views which display specific data. This data could be a list of posts, a single post or an RSS feed.
It is the route that determines what data is meant to be shown and what template is used to render it.
For example, a post on a new publication with the/welcome-to-ghost/
URL is intended to show the content of the post, so the post.hbs
template is be used, as well as some global data from default.hbs
. This is called the post
context and occurs whenever you view a single post.
Rather than providing access to all data in all contexts, Ghost optimises what data is fetched using contexts to ensure publications are super fast.
Ghost发布遵循的结构允许将url或路由映射到显示特定数据的视图。这些数据可以是一组文章、一篇文章或一个RSS提要。
它是决定要显示什么数据和使用什么模板来呈现数据的路由。
例如,在新发布的出版物POST上使用/welcome-to-ghost/ URL来显示文章的内容。使用了hbs模板,以及一些default.hbs的全局数据。这称为post上下文,在查看单个post时发生。
Ghost不是在所有上下文中提供对所有数据的访问,而是使用上下文来优化获取的数据,以确保发布的速度非常快。
Contexts play a big part in the building blocks of a Ghost theme. Besides determining what data is available and what template to render, contexts also interact with helpers, since the context also determines what dynamic data the helper outputs.
For example, the {{meta_title}}
helper outputs different things based on the current context. If the context is post
then the helper knows it can use post.meta_title
and in a tag
context it uses tag.meta_title
.
To detect a context in your theme, use the {{is}}
helper. For example, in a partial template that is shared between many contexts, using {{is}}
will pass it a context and only execute the contained block when it is in that context.
上下文在Ghost主题的构建块中扮演着重要的角色。除了确定可用的数据和要呈现的模板之外,上下文还与帮助程序交互,因为上下文还确定帮助程序输出的动态数据。
例如,{{meta_title}} helper根据当前上下文输出不同的内容。如果上下文是post,那么帮助器知道它可以使用 post.meta_title
。在标签上下文中,它使用tag.meta_title。
要检测主题中的上下文,请使用{{is}}助手。例如,在许多上下文之间共享的部分模板中,使用{{is}}将传递给它一个上下文,并且仅当它在该上下文中时才执行所包含的块。
GHOST CMS -上下文概述 Context Overview
标签:url ensure 程序 themes title exec handle rac ati
原文地址:https://www.cnblogs.com/QDuck/p/12080301.html