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}}将传递给它一个上下文,并且仅当它在该上下文中时才执行所包含的块。
GHOST CMS -上下文概述 Context Overview的更多相关文章
- 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 - 终 ...
- Tomcat部署web项目,虚拟目录,上下文(Context),WEB-INF,web.xml,servlet,404
Web项目的uri模型大致如下: http://localhost:8080 (/context) (/resource) 站点/上下文/资源 一. Tomcat中指定上下文(Context) 方法一 ...
- javascript作用域(Scope),简述上下文(context)和作用域的定义
网页制作Webjx文章简介:这篇文章将正面解决这个问题:简述上下文(context)和作用域的定义,分析可以让我们掌控上下文的两种方法,最后深入一种高效的方案,它能有效解决我所碰到的90%的问题. 作 ...
- 层叠上下文 Stacking Context
层叠上下文 Stacking Context 在CSS2.1规范中,每个盒模型的位置是三维的,分别是平面画布上的x轴,y轴以及表示层叠的z轴.对于每个html元素,都可以通过设置z-index属性来设 ...
- (转)Docker镜像构建上下文(Context)
镜像构建上下文(Context) Docker在构建镜像时,如果注意,会看到 docker build 命令最后有一个 ... 表示当前目录,而 Dockerfile 就在当前目录,因此不少初学者以为 ...
- Docker镜像构建上下文(Context)
镜像构建上下文(Context) Dicker在构建镜像时,如果注意,会看到 docker build 命令最后有一个 ... 表示当前目录,而 Dockerfile 就在当前目录,因此不少初学者以为 ...
- Flask 上下文(Context)原理解析
:first-child { margin-top: 0; } blockquote > :last-child { margin-bottom: 0; } img { border: 0; m ...
- 上下文(Context)和作用域(Scope)
函数的每次调用都有与之紧密相关的作用域和上下文.从根本上来说,作用域是基于函数的,而上下文是基于对象的. 换句话说,作用域涉及到所被调用函数中的变量访问,并且不同的调用场景是不一样的.上下文始终是th ...
- OpenJDK源码研究笔记(十三):Javac编译过程中的上下文容器(Context)、单例(Singleton)和延迟创建(LazyCreation)3种模式
在阅读Javac源码的过程中,发现一个上下文对象Context. 这个对象用来确保一次编译过程中的用到的类都只有一个实例,即实现我们经常提到的"单例模式". 今天,特意对这个上下文 ...
随机推荐
- Java求吸血鬼数算法(通用)
/*吸血鬼数字是指位数为偶数的数字,可以由一 * 对数字相乘而得到,而这对数字各包含乘积的一半位数的数字, * 其中从最初的数字中选取的数字可以任意排序. * 以两个0结尾的数字是不允许的. * * ...
- 驰骋工作流系统-Java共工作流引擎配置定时任务
关键词:工作流定时任务 流程引擎定时任务设置 工作流系统定时任务配置 开源工作流引擎 开源工作流系统 一.定时任务的作用 发送邮件,发送短信. 处理节点自动执行的任务.比如:一个节点的待办工作是 ...
- 视频转GIF+GIF录制
GIF录制 Windows--oCam oCam使用非常简便,它还可以用来录音,录制视频,并且是单文件版,很小,使用也非常方便,如果用来录制GIF,大家导出录制的视频选择GIF格式就可以了: Wind ...
- day 12 函数名的应用 闭包 迭代器
今日主要内容 1, 函数名的应用,第一类对象 函数名可以像变量一样进行使用 #再函数名后面添加() 才是对函数的调用, 否则打印的是函数的内存地址 1.赋值 2.作为list元素 3.作为参数 d ...
- JSONPath小试牛刀之Snack3
最近在网上看了些JSONPath的入门例子.打算用Snack3这个框架写写例子.json path对`JSON的处理绝对是神器. 1.准备JSON字符串 { "store": { ...
- P1307 数字反转
题目描述 给定一个整数,请将该数各个位上数字反转得到一个新数.新数也应满足整数的常见形式,即除非给定的原数为零,否则反转后得到的新数的最高位数字不应为零(参见样例2). 输入输出格式 输入格式: 一个 ...
- 【RN - 基础】之View使用简介
简介 View是一个容器,支持FlexBox布局. View既可以作为容器容纳其他组件,也可以作为一个组件包含进另一个容器中. 无论运行在哪个平台上,View都会直接对应这个平台的原生视图,如iOS中 ...
- 在开发Thinkphp5.0智慧软文个人微信个人支付宝企业支付宝接口时遇到的坑
在开发Thinkphp5.0智慧软文个人微信个人支付宝企业支付宝接口时遇到回调后提示成功但是不能自动充值的情况,现在记录一下: 两种情况 1.个人支付宝 个人微信遇到的情况 因为个人支付宝 个人微信 ...
- HTML+CSS的小实例
通过一个月以来对HTML5+CSS的学习.这篇随笔给大家来做一个简单的网页中常见的导航栏. 这些都称之为网页中的导航栏. 我简单的做了一个某宝和58同城的导航栏,供大家学习参考. 一.58同城导航栏: ...
- Spring底层源码分析
Spring 运行原理 Spring 启动时读取应用程序提供的 Bean 配置信息,并在 Spring 容器中生成一份相应的Bean 配置注册表,然后根据这张注册表实例化 Bean,装配好 Bean ...