定制 roxburghm/twig-hhandlebars 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

roxburghm/twig-hhandlebars

Composer 安装命令:

composer require roxburghm/twig-hhandlebars

包简介

A twig preprocessing loader that converts {{{ }}} to {{ }} allowing twig template of VueJS etc

README 文档

README

Pun: H-Handlebars, extra H because of extra curly brace.

This Twig Preprocessor, heavily based on [https://github.com/TiGR/twig-preprocessor] allows you to use {{{ }}} handlebars in a twig template which are rendered out in the final twig as {{ '{{' }} and {{ '}}' }}.

This allows you to mix twig and other handlebar delimited code, eg VueJS or handlebars.js, in the same template.

This branch (master) contains code for Twig 2.x.

Installation

Installation via composer (version for twig 2):

composer install roxburghm/twig-hhandlebars

Usage

Intantiate a real template loader and then wrap that in a HHandlebars loader before passing to Twig.

Intantiate Twig

$realLoader = Twig_Loader_Filesystem('/path/to/templates');
$twig = new Twig_Environment(new Twig_Loader_HHandlebars($loader));

Template Usage

<h1>Hello {{ twigvar_user.name }}</h1>

<div id="app">
  {{{ message }}}
</div>

var app = new Vue({
  el: '#app',
  data: {
    message: 'Hello Vue!'
  }
})

The code is rendered out correctly without having to resort to changing delimiters anywhere in eithe Twig or, say, VueJS.

Just in case you like to live dangerously and nest preprocessors in other languages this preprocessor will convert triple handlebars to double as you would expect but ALSO convert quadruple to triple.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-03-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固