heyday / silverstripe-templatehelpers
为 Silverstripe 提供简单模板功能
3.0.0
2023-07-19 02:09 UTC
README
这是一个由 SilverStripe 模板开发者使用的常用功能库。
安装(使用 composer)
$ composer require heyday/silverstripe-templatehelpers
使用方法
安装完成后,以下函数可在任何 .ss 模板中使用
$isDev
- 如果网站正在开发环境中运行$isTest
- 如果网站正在测试环境中运行$isLive
- 如果网站正在生产环境中运行$ImagePath('my-image.png')
- 根据当前环境的配置构建一个图片路径$addInlineScript('/path/in/theme/directory/file.js')
- 在模板中直接包含一个 JavaScript 文件(注意,自动生成<script>
标签,因此需要手动添加这些标签)。
$ImagePath
配置
默认情况下,图片路径助手为 themes/[theme]/images/
。主题目录内的路径可以在项目的 YAML 配置中进行配置。
TemplateHelpers: dev_images: source/images prod_images: production/images