GHOST CMS -上下文概述 Context Overview

Context Overview上下文概述

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}}助手输出什么内容。

What is a 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发布遵循的结构允许将url或路由映射到显示特定数据的视图。这些数据可以是一组文章、一篇文章或一个RSS提要。

它是决定要显示什么数据和使用什么模板来呈现数据的路由。

例如,在新发布的出版物POST上使用/welcome-to-ghost/ URL来显示文章的内容。使用了hbs模板,以及一些default.hbs的全局数据。这称为post上下文,在查看单个post时发生。

Ghost不是在所有上下文中提供对所有数据的访问,而是使用上下文来优化获取的数据,以确保发布的速度非常快。

Using contexts使用上下文

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}}将传递给它一个上下文,并且仅当它在该上下文中时才执行所包含的块。

原文地址:https://www.cnblogs.com/QDuck/p/12080301.html

时间: 2024-07-29 13:23:24

GHOST CMS -上下文概述 Context Overview的相关文章

GHOST CMS - 索引Index

Index Use: {{#is "index"}}{{/is}} to detect this context. 使用:{{#is "index"}}{{/is}}来检测这个上下文. Description描述 index is the name for the main post list in your Ghost site, the index context includes the home page and subsequent pages of th

ZeroMQ接口函数之 :zmq_term - 终结ZMQ环境上下文(context)

ZeroMQ 官方地址 :http://api.zeromq.org/4-0:zmq_term zmq_term(3) ØMQ Manual - ØMQ/4.1.0 Name zmq_term - 终结ZMQ环境上下文(context) Synopsis int zmq_term (void *context); Description zmq_term()函数将终结环境上下文context. 函数 zmq_ctx_term() 会销毁ZMQ环境上下文context. 环境上下文的终止过程会按下

Tomcat部署web项目,虚拟目录,上下文(Context),WEB-INF,web.xml,servlet

Web项目的uri模型大致如下: http://localhost:8080 (/context) (/resource) 站点/上下文/资源 一. Tomcat中指定上下文(Context) 方法一,位于webapps文件夹中的web项目,无需指定Context,Tomcat默认解析为该web项目根文件夹的名称,即为真实目录名称. 方法二,在server.xml中指定Context. 编辑conf\server.xml文件,在元素之间加入子元素,内容如下: <Context docBase=”

Docker镜像构建上下文(Context)

镜像构建上下文(Context) Dicker在构建镜像时,如果注意,会看到 docker build 命令最后有一个 ... 表示当前目录,而 Dockerfile 就在当前目录,因此不少初学者以为这个路径是在指定 Dockerfile 所在路径,这么理解其实是不准确的.如果对应上面的命令格式,你可能会发现,这是在指定上下文路径.那么什么是上下文呢? 首先我们要理解 docker build 的工作原理.Docker 在运行时分为 Docker 引擎(也就是服务端守护进程)和客户端工具.Doc

GHOST CMS - 配置 Config

Config For self-hosted Ghost users, a custom configuration file can be used to override Ghost's default behaviour. This provides you with a range of options to configure your publication to suit your needs. 对于自承载的Ghost用户,可以使用自定义配置文件覆盖Ghost的默认行为.这为您提供

渲染上下文Rendering Context

渲染描述表,包含一次渲染所需的全部数据.用于提交给游戏渲染引擎的渲染器进行渲染 -------------------------------------------------------------------- 如果把渲染引擎看做一个画家,那么画家开始作画之前需要做一系列的准备工作,譬如:布置好场景,摆好画架,钉好画布,调整好灯光,准备号画笔油彩,站好位置,然后才能开始下笔作画. 前期的这一系列准备过程在D3D和Ogl这样的渲染Api中对应了一系列的接口函数,这些函数初看起来又多又乱,有时

Android开发之Android Context,上下文(Activity Context, Application Context)

转载:http://blog.csdn.net/lmj623565791/article/details/40481055 1.Context概念Context,相信不管是第一天开发Android,还是开发Android的各种老鸟,对于Context的使用一定不陌生~~你在加载资源.启动一个新的Activity.获取系统服务.获取内部文件(夹)路径.创建View操作时等都需要Context的参与,可见Context的常见性.大家可能会问到底什么是Context,Context字面意思上下文,或者

十六、Python 上下文管理 Context Manager

要使用 with 语句,首先要明白上下文管理器这一概念.有了上下文管理器,with 语句才能工作.下面是一组与上下文管理器和with 语句有关的概念. 上下文管理协议(Context Management Protocol):包含方法 __enter__() 和 __exit__(),支持该协议的对象要实现这两个方法. 上下文管理器(Context Manager):支持上下文管理协议的对象,这种对象实现了__enter__() 和 __exit__() 方法.上下文管理器定义执行 with 语

GHOST CMS - Data Helpers

Data Helpers Data helpers are used to output data from your site. Use this reference list to discover what each handlebars helper can do when building a custom Ghost theme. Available data helpers @config @site navigation post url title img_url excerp