承接 smcgarrity/rhubarb-module-leaf-twigview 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

smcgarrity/rhubarb-module-leaf-twigview

Composer 安装命令:

composer require smcgarrity/rhubarb-module-leaf-twigview

包简介

Twig integrated View for Rhubarb

README 文档

README

Integration of Twig HTML template engine in a Rhubarb View.

Creating a Twig View

To create a twig view simply create a View that extends the TwigView class.

class ProductDetailsView extends TwigView

You will be have to implement two methods:

getTwigFileLocation() should return the location of your .twig or .html file as a string.

function getTwigFileLocation(): string
{
    return __DIR__ . '/File.twig';
}

getTwigVariables() returns an array of values you want to be available in your Twig Template.

function getTwigVariables() {
    return [
        'PageTitle' => 'Edit Page', 
        'Type' => $this->model->restModel->Type,
        'NameInput' => $this->leaves['NameTextbox'],
    ];
}

You will also need an actual Twig File to be compiled. Twig can compile any HTML file, but has additional support for twig features such as controls and variables. To format twig inputs use the PHPStorm .twig file.

TwigView uses the printViewContent method to render the HTML so if you extend printViewContent ensure to include a parent call.

Using Twig

Twig uses brackets { } to insert variables and controls into a HTML template.

A variable can be output directly using double brackets.

<p>{{ date }}</p> 

Objects can be access with dot notation in the same way:

<p>Dear {{ recipient.Name }},</p> 

Controls can be added using {% %}.

{% for purchase in purchases  %} 
    {% if purchase.cancelled %} 
        <p class="red">You cancelled your purchase of a {{purchase.product}} on {{purchase.date}} 
    {% else %} 
        <p> you purchased a {{purchase.product}} on {{purchase.date}} for {{purchase.price}}</p> 
    {% endif %} 
{% endfor %} 

Full Twig Documentation: https://twig.symfony.com/doc/2.x/

统计信息

  • 总下载量: 23
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2018-03-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固