GHOST CMS - Overview of context Context Overview

Context Overview overview of context

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 theme of each page belongs to a context that determines which template to use, what data is available and {{body_class}} output what aides.

What is a context? What is the context

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 release allows the mapping structure follows url or routing data to display a particular view. These data can be a set of articles, an article or a RSS feed.

It is to decide what data and what routing template to render data to be displayed.

For example, using / welcome-to-ghost / URL in a new publication released POST to display the contents of the article. Hbs use templates, as well as some of default.hbs of global data. This is called post context, occurs when viewing a single post.

Ghost is not available in all contexts access to all the data, but the use of context to optimize data acquisition to ensure that released very quickly.

Using contexts using context

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.

Context plays an important role in building blocks Ghost topic. In addition to determining the available data and templates to be presented outside the context also with the help of the interactive program, because the context of dynamic data also help determine the program's output.

For example, {{meta_title}} helper according to the output of the current context different content. If the context is the post, then the helper knows it can use  post.meta_title. In the context of the label, it uses tag.meta_title.

To detect context topic, use {{is}} assistant. For example, in many contexts shared between the portion of the template using {{is}} a context passed to it, and if it is performed only when the block in this context included.

Guess you like

Origin www.cnblogs.com/QDuck/p/12080301.html