causal/fluid-standalone-renderer

Fluid独立渲染引擎

0.2.0 2017-11-28 15:51 UTC

This package is auto-updated.

Last update: 2024-09-07 19:40:17 UTC


README

作为一个设计师/集成者,这个包允许你在将模板实际集成到完整的TYPO3网站之前轻松地渲染模板和部分。

当设计师团队在模板文件(HTML/CSS/JS)上工作并提供现成的资产给TYPO3集成团队时,这特别有用。

安装

  1. 使用composer require causal/fluid-standalone-renderer将此作为composer依赖项包含
  2. 运行composer install以生成供应商类自动加载器

分发器

然后你需要在你的设计项目中创建一个简单的index.php(或你想要的任何名称)脚本

<?php
require __DIR__ . '/vendor/autoload.php';

$htmlPath = __DIR__ . '/Resources/Private/';
$dataPath = __DIR__ . '/Resources/Private/Samples/';

$server = new \Causal\FluidStandaloneRenderer\Server(
    basename(__FILE__),
    $htmlPath,
    $dataPath
);

echo $server->run();

从你的浏览器执行此脚本将显示在Resources/Private/Templates/Resources/Private/Partials/下可用的各种模板和部分。

示例数据

比如说,你有一个以下的部分Resources/Private/Partials/Foo/Bar.html

<html xmlns="http://www.w3.org/1999/xhtml" lang="en"
      xmlns:f="http://typo3.org/ns/TYPO3/Fluid/ViewHelpers"
      data-namespace-typo3-fluid="true">

<span class="label label-default">
    {title}
    <f:if condition="{subtitle}">
        <small>({subtitle})</small>
    </f:if>
</span>

</html>

然后你可以创建一个包含示例数据的文件Resources/Private/Samples/Partials/Foo/Bar.json

{
  "title": "My sample title",
  "subtitle": "My sample subtitle"
}

规则是,示例数据存储在与相应的"模板"完全相同的目录结构和名称中,但不是以.html结尾,而是以.json结尾。